Parameters in C++ OOP

Hello tehre,

I am trying to make a class but i can't use some parameters in my function

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
33
34
35
#include <iostream>

using namespace std;

class Test {

    public:

    char Name[50];
    
    void changeName(char NewName)
    {
        Name = NewName;
    }
    
    void showName()
    {
        cout << endl << "Name:" << Name;
    }

};

int main()
{

    Test t;
    
    t.changeName("Hello World!");
    t.showName();

    system("PAUSE >nul");
    
    return 0;

}


I am getting the error:
34; main.cpp invalid conversion from `const char*' to `char'

Can someone help me please :)!
oops, wrong topic..
Last edited on
Well, in your function changeName you get a character as a parameter but pass a string in main, perhaps you wanted to get a char*?
Topic archived. No new replies allowed.