Splitting a program across multiple files

Hi, I'm learning how to use multiple files for a single program, I made a successful example in which I called a member of a class in another cpp file. But when I tried to pass a parameter it stopped working and I don't have the slightest idea why. Can you help me?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
*******************
main.cpp:
*******************
#include <iostream>
#include "out.h"

int main()
{   float var;
    std::cin >> var;
    out::out(var);
    return 0;}

*******************
out.h:
*******************
#ifndef OUT_H
#define OUT_H

class out
{   public:
        out(float);};

#endif // OUT_H

*******************
out.cpp:
*******************
#include <iostream>
#include "out.h"

out::out(float var)
{   std::cout << var;}


ERRORS:
In function 'int main()':
line 7 error: conflicting declaration 'out var'
line 5 error: 'var' has a previous declaration as 'float var'
You need to instanciate your class like this:

out myInstance(var);
thanks
Topic archived. No new replies allowed.