This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: create an object with variable CLASS
- From: "John (Eljay) Love-Jensen" <eljay at adobe dot com>
- To: "mohsen at pahlevanzadeh dot org" <mohsen at pahlevanzadeh dot org>
- Cc: GCC-help <gcc-help at gcc dot gnu dot org>
- Date: Tue, 27 Oct 2009 04:16:48 -0700
- Subject: 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