Link to home
Start Free TrialLog in
Avatar of edelossantos
edelossantos

asked on

class A

#include <iostream>

using namespace std;

class A {

public:

   A(int x, double y, char z) {a=x;
                               b=y;
                               c=z;
                                        }

   ~A();

private:

   int a;
   double b;
   char c;

};

int main()
{
   int obj(2, 20.0, 'a');
   int obj_2;

   obj_2 = obj;

}

output:

classA.cpp: In function `int main()':
classA.cpp:26: initializer list being treated as compound expression
SOLUTION
Avatar of Sys_Prog
Sys_Prog
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of edelossantos
edelossantos

ASKER

Now I am getting this, couldn't figure out.

#include <iostream>

using namespace std;

class A {

public:

   A(int x, double y, char z) {a=x;
                         b=y;
                         c=z;
                              }

   ~A();

private:

   int a;
   double b;
   char c;

};

int main()
{
   A obj(2, 20.0, 'a');
   A obj_2;

   obj_2 = obj;

}


output:

classA.cpp: In function `int main()':
classA.cpp:27: no matching function for call to `A::A ()'
classA.cpp:9: candidates are: A::A(int, double, char)
classA.cpp:22:                 A::A(const A &)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
#include <iostream>

using namespace std;

class A {

public:

   A(int x, double y, char z){
        a = x;
        b = y;
        c = z;

   }

   ~A(){};

private:

   int a;
   double b;
   char c;

};

int main()
{
   A obj(2, 20.0, 'a');
   A obj_2;


}

output:

classA.cpp: In function `int main()':
classA.cpp:29: no matching function for call to `A::A ()'
classA.cpp:9: candidates are: A::A(int, double, char)
classA.cpp:24:                 A::A(const A &)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial