That is not correct. Look carefully at the req->inst. So, when you initialise the Dip object, you need to set its inst member accordingly.Originally Posted by amahmoo
Refer to my post #8.Originally Posted by amahmoo
That is not correct. Look carefully at the req->inst. So, when you initialise the Dip object, you need to set its inst member accordingly.Originally Posted by amahmoo
Refer to my post #8.Originally Posted by amahmoo
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
it doesnt have any value
would i havet o allocate memory for struct in main then set a value for inst and then call it ? can you show me how to do it?
Look carefully at the req->inst. So, when you initialise the Dip object, you need to set its inst member accordingly.
how do i iinitialize dip?
how do i set member accordingly through main
You probably just need to declare an object of type Dip, and then set its member to your desired value.Originally Posted by amahmoo
Refer to the earlier posts in this thread and also to your learning material.Originally Posted by amahmoo
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Code:dip * req =(dip*)malloc(sizeof(dip);how do i declare object how do i set member to desired value?Code:
No, do not use malloc. And um, why does the type name keep changing?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
i did it on accident
its same as before
i just typed fast
then what am i supposed to use if not malloc
Keep it simple:Originally Posted by amahmoo
Code:Dip req;
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Dip req;
req-> instance = x;
func(x);?
Give it a try. Your compiler will give you some error messages. Read them carefully and try to understand them. This is a good learning experience.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
prog.c:9:1: error: unknown type name 'bool_t'
bool_t func( Dip* req )
^
prog.c:9:14: error: unknown type name 'Dip'
bool_t func( Dip* req )
^
prog.c: In function 'main':
prog.c:30:5: error: unknown type name 'Dip'
Dip req;
^
prog.c:31:8: error: invalid type argument of '->' (have 'int')
req-> instance = x;
^
prog.c:31:22: error: 'x' undeclared (first use in this function)
req-> instance = x;
^
prog.c:31:22: note: each undeclared identifier is reported only once for each function it appears in
prog.c:32:5: warning: implicit declaration of function 'func' [-Wimplicit-function-declaration]
func(x);
^
Last edited by amahmoo; 11-23-2015 at 12:23 PM.
What do you understand of these error messages?
And um, you really need to post your code.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
it doesnt know whot bool_t is
doesn't know what DIP is
doesn;t know type of DIP
prog.c:31:8: error: invalid type argument of '->' (have 'int')
req-> instance = x;->>>>>>>> i am passing int when there is no int
x is undeclared
there is a missing prototype in implixict declaration