Hi guys, I'm making a game in C++, is it possible to pass a struct variable to a routine by reference?
thanks!
i mean a regular struct, like
1 2 3 4 5
|
struct Document
{
char Name[20];
char Lastname[20];
}
|
i need routines to modify several values of the struct, so i'd rather have one routine that modifies all
Last edited on
In C++, iirc, structs can contain functions.
Or you can declare them as private, and have an object of type myStruct. Then use the object to modify values.
I'm still not sure what you're trying to do.
don't worry, i've found out how:
1 2 3 4 5
|
struct Document
{
char Name[20];
char Lastname[20];
}
|
supposing i need a routine to change the last name, i call it in main like this:
Changelname(&Mydoc)
and in the routine...
1 2 3 4
|
Document Changelname(Document* Mydoc)
{
strcpy((*Mydoc).Lastname,"Something");
}
|
it was unguessable, lucky 4 me a friend of mine knew this, now i hope it helps for anyone with a similar problem
Thanks!!!
Last edited on