-13

I am making a stack class, and trying to make an object of it and using it in another class. However, it mentions that there is an error. here's my code of intializing the stack object in the class:

class functions{
public:
int m[5];
int c=0;
stack_x mem(5);
Mee
  • 1,413
  • 5
  • 24
  • 40

2 Answers2

7

You can't initialise members using parentheses in the class definition.
Use curly braces — stack_x mem{5};.

molbdnilo
  • 64,751
  • 3
  • 43
  • 82
0

If the previous class (stack_x) looks like an custom class its correctly closed

class stack_x
{
 // Class definition
}; // MUST BE

class functions
{
// Class definition
};
Pablo
  • 82
  • 6
  • I did so, but still not works, i only copied the part of intialzing the object of stack_x class in functions class – Mee Apr 15 '19 at 13:33