I am trying to understand what is a constructor and could you tell me why I am still able to run the program without error?
As you can see I am not doing it correctly but it still works!! why?? and when I tried to put LL=(object name ) after my class DELL it is not working? but when I retrieved the LL it works why??? If I am not clear do not hesitate to tell me and I am sorry in advance for this mess
#include <iostream>
#include <string>
using namespace std;
class DELL{
public:
DELL(){
cout <<" bla bl bla\n";
}
void setname(string x){
name = x;
}
string getname()
{
return name;}
private:
string name;
};
int main(){
DELL (); // Variant 1
DELL LL(); // Variant 2
return 0;
}