-
I don't get this
Code:
#include "Project1App.h"
#include "Project1Frm.h"
#include <string>
string n;
IMPLEMENT_APP(Project1FrmApp)
bool Project1FrmApp::OnInit()
{
Project1Frm* frame = new Project1Frm(NULL);
SetTopWindow(frame);
frame->Show();
return true;
}
int Project1FrmApp::OnExit()
{
return 0;
}
Error: 15 C:\wxdevcpp\proiecte\1st\Project1App.cpp `string' does not name a type
I'm trying to declare a vector visible outside the wx implementation, but that did not work, so i cam back to an int. It worked, char worked, but string and any other standard class, doesn't. This is so annoying. I almost thought I got the smallest hang of C++.
-
-
oh. what's std, and what does :: do?
-
std is a namespace, which is particular to C++ and not in the C language.
Namespaces are essentially a way to group data and functions under a unique name. This gets rid of the problem of having name collisions which are a compiler error. the std namespace incorportates functions and data from the Standard Template Library (STL). The :: operator is called the scope-resolution operator and explicity tells the compiler what class or namespace you want to use.
-
Instead of writing out "std::string" everytime, consider adding a line "using std::string;" at the top. Some people use "using namespace std;" to import the whole namespace, but many others don't like that idea.
-
Hmm, sounds like a pretty smart addition to the basic C. I'll have to experiment with it. Thanks!