1) You're mistaken. TeslaLogin - is not a class. It's a simple struct, that has 4 variables for storing host, pass, database and login information.
Declaration looks like this:
1 2 3 4 5 6
|
struct TeslaLogin {
char login[40];
char pass[40];
char host[40];
char database[40];
};
|
As you see, it's a simple struct for storing data. No functions ot constructors at all.
Edit: Do you get an stack overflow? Does the program end? |
No. Well, seems I explained badly my problem. Well... Imagine, I have Firefox brobser. It has module support. It would be bad, if each module for example should redowload each page you visit to work with data, isn't it? The same story here. I need only one database connection to setup per all modules and entire program.
But... It crashes after second level or I need to make constructor to recreate entire class each time in automatic mode.
Take a look... Programm starts, I connect to DB(DataBase), then, I store it as *DB type(pointer). Then, fuctions and classes are quite a lot, over 30 000 of programm code(I mean all CPP, not H files).
Then, it should work as this:
1 2 3 4 5 6 7 8 9 10
|
SomeClass *test1;
test1 = new SomeClass;
//THE ONLY INITIALIZATION
RunTest1(test1);
RunTest1(SomeClass *test)
{
///SOME ACTIONS HERE
RunTest2(test); ////HERE CLASS POINTER DATA IN SOME REASONS LOST
}
|
Hope this time I made myself clear. I need some data to initialize only once peer all program, no matter how many times and how deep this usage goes. But after second level class begins creating "new" instead of using already existing.