This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: create an object with variable CLASS


Hi Mohsen

> My main file:
> int main(){
> module_management *x;
> x.printg();
> }

In your code, x is a wild pointer.

You need to do either:

int main()
{
  module_management x;
  x.printg();
}

Or:

int main()
{
  module_management* x = new module_management;
  x->printg();
  delete x;
}

(You can replace new module_management with some other suitable factory
function that you have written.)

HTH,
--Eljay


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]