I'm trying to learn classes in C++ but i'm unable to understand what's happening here.
#include<iostream>
#include<string>
class Dummy{
public:
std::string name;
void setName(std::string input){
name = input;
}
};
int main(){
Dummy obj;
obj.setName("John");
Dummy obj1(); // error in this line
obj1.setName("John");
}
Error:
prog.cpp: In function ‘int main()’:
prog.cpp:18:10: error: request for member ‘setName’ in ‘obj1’, which is of non-class type ‘Dummy()’
18 | obj1.setName("John");
| ^~~~~~~