Topic: Passing char * parameters
Author: michaelc@lna.logica.com
Date: Thu, 15 Sep 1994 13:44:24 GMT Raw View
> I'm taking a C++ class at school
I vote we change the name of this newsgrope.
M.
Author: mwt@lightside.com (Mark Thompson)
Date: 10 Sep 1994 21:10:30 GMT Raw View
To All,
I'm taking a C++ class at school where we were told to write a database
update program and to make bar menus where appropriate. I decided to
see if, instead of creating a new class for each menu as the instructor
said, I could make a generic menu class usable during the entire
program.
I'm having a problem getting the data pointer set.
I have a function embedded in a class called menu that is set up
this way. The actual class definition is listed below the class
function. The problem that I am having is that it says the data =
line has a syntax error.
I'm anticipating calling the function from main() and other classes like
this
menu::setdata("Database Options",{"Add","Delete","Edit","List","Quit"},5);
The actual function looks like this:
void menu::setdata(const char * getheader, const char * getdata[],
int getnumoptions)
{
header = new char[sizeof( getheader )+1];
data = new char[sizeof(getdata) + 1][getnumoptions];
}
This is the class declarations.
class menu
{
private:
char * header;
int headeryloc;
int headerxloc;
char * data[];
int dataxloc;
int datayloc;
int dataspacing;
int numoptions;
int clearscreen;
public:
int run();
void setdisplay(int,int,int,int,int,int);
void setdata(const char *, const char * [], int);
};
I'm kindof new to C++, but I'm catching on pretty fast. If anyone has
any idea what I've done wrong, please post or E-mail me. Since I'm new
to C++, I'm not positive that I've given enough information. If anyone
needs more info to figure out what's wrong, please write and I'll give
whatever you need.
Thanks in advance,
Mark Thompson
-=-=-=-=-=-=-
mwt@lightside.com
West Covina, California