Home > Software engineering >  Some problems about MFC, help!!!!!
Some problems about MFC, help!!!!!

Time:11-08

Predecessors, in the same project in VS2019, because the project need I create multiple classes, and then in a main CPP, I built a open a TXT file, read the data of the function (is student management system, a TXT file store student information, including name, student id) results in all the subjects, now I want to use these data in another CPP should be how to do?

CodePudding user response:

Hope that they can help me know predecessors

CodePudding user response:

Open a TXT file, read the data as a function of "put the App class
With theApp you can access

CodePudding user response:

Is a function of the reading in the header file? Then declare this header file

CodePudding user response:

Such as
The class CHMI_man App : public CWinApp
{
Public:
CHMI_manApp ();
Virtual ~ CHMI_manApp ();

BOOL Check802Service ();
.

BOOL CHMI_manApp: : Check802Service ()
{//if no error return TRUE
return FALSE;
}

CodePudding user response:

refer to the original poster small north also want stronger reply:
good predecessors, in the same project in VS2019, because the project need I create multiple classes, and then in a main CPP, I built a open a TXT file, read the data of the function, is the student management system, a TXT file store student information, including name, student id) results in all the subjects, now I want to use these data in another CPP should be how to do?



Design patterns to understand?
Singleton pattern can solve your this problem, because the database is only a,

The class Database
{
Public:
The static Database * Instance ()
{
If (m_intance==NULL)
{
M_intance=new Database ();
}
Return m_intance;
}

Private:
The Database * m_intance=NULL;
};

CodePudding user response:

The singleton pattern, all global variables can be solved your problem

CodePudding user response:

reference about MFC SDI

CodePudding user response:

refer to fifth floor walk every step response:
Quote: refer to the building of small north is stronger response:

Predecessors, in the same project in VS2019, because the project need I create multiple classes, and then in a main CPP, I built a open a TXT file, read the data of the function (is student management system, a TXT file store student information, including name, student id) results in all the subjects, now I want to use these data in another CPP should be how to do?



Design patterns to understand?
Singleton pattern can solve your this problem, because the database is only a,

The class Database
{
Public:
The static Database * Instance ()
{
If (m_intance==NULL)
{
M_intance=new Database ();
}
Return m_intance;
}

Private:
The Database * m_intance=NULL;
};

Thank you bosses!!!!!!

CodePudding user response:

refer to fifth floor walk every step response:
Quote: refer to the building of small north is stronger response:

Predecessors, in the same project in VS2019, because the project need I create multiple classes, and then in a main CPP, I built a open a TXT file, read the data of the function (is student management system, a TXT file store student information, including name, student id) results in all the subjects, now I want to use these data in another CPP should be how to do?



Design patterns to understand?
Singleton pattern can solve your this problem, because the database is only a,

The class Database
{
Public:
The static Database * Instance ()
{
If (m_intance==NULL)
{
M_intance=new Database ();
}
Return m_intance;
}

Private:
The Database * m_intance=NULL;
};

Thank you bosses!!!!!!

CodePudding user response:

refer to fifth floor walk every step response:
Quote: refer to the building of small north is stronger response:

Predecessors, in the same project in VS2019, because the project need I create multiple classes, and then in a main CPP, I built a open a TXT file, read the data of the function (is student management system, a TXT file store student information, including name, student id) results in all the subjects, now I want to use these data in another CPP should be how to do?



Design patterns to understand?
Singleton pattern can solve your this problem, because the database is only a,

The class Database
{
Public:
The static Database * Instance ()
{
If (m_intance==NULL)
{
M_intance=new Database ();
}
Return m_intance;
}

Private:
The Database * m_intance=NULL;
};

Thank you bosses!!!!!!

CodePudding user response:

A complete this student management system procedures, can be directly run, class query results query, sorting, achievements recorded, student number query and name query, add, delete, modify, is not only a student, teacher the corresponding functions are very perfect,

CodePudding user response:

Two classes need to share data when a data object classes, and then pass the pointer between classes
Like you want to pass a string between two classes, MFC is also encapsulate a string and then pass the pointer