Visual Studio.NET C++ 2005 Express, functions defined in cpp file cause "is not class or na
I am not sure if this is the correct group for this question, but I couldn't find a more appropriate one.
I have Visual Studio.NET C++ 2005 Beta 2 installed and I was trying my hand at creating a simple Windows application. I have a main form that I used the desinger to create with splitContainer. The top container I want to swap out forms depending upon the user selection.
I create a class that inherts from System::Windows::Forms:Form. I used the designer again to create the controls, but which are declared in the header file. The namespace is SDUDataLogger and the class is declared as the following in the header file
namespace SDUDataLogger
{
public ref class frmRunTimeDataLog:: public
System::Windows::Forms::Form
public:
frmRunTimeDataLog(void);
// A ton of other code removed to just focus on ctor
}
I wanted to implement all the functions in a cpp file as I don't like the idea of have all the implementation in the header file. So I create a cpp file called frmRunTimeDataLog.cpp which looks like ( I just copied what was in the header file to the new cpp file and made the function declaration in header file as a prototype.
namespace SDUDataLogger
{
#include "StdAfx.h"
#include "frmRunTimeDataLog.h"
frmRunTimeDataLog::frmRunTimeDataLog(void)
{
frmRunTimeDataLog::InitializeComponent();
//
//TODO: Add the constructor code here
//
}
}
When I compile the cpp file I get the following errors...
.\frmRunTimeDataLog.cpp(17) : error C2653: 'frmRunTimeDataLog' : is not a class or namespace name
.\frmRunTimeDataLog.cpp(18) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
.\frmRunTimeDataLog.cpp(19) : error C3861: 'InitializeComponent': identifier not found
.\frmRunTimeDataLog.cpp(23) : warning C4508: 'frmRunTimeDataLog' : function should return a value; 'void' return type assumed
.\frmRunTimeDataLog.cpp(25) : error C2059: syntax error : '}'
.\frmRunTimeDataLog.cpp(25) : error C2143: syntax error : missing ';' before '}'
.\frmRunTimeDataLog.cpp(25) : error C2059: syntax error : '}'
I changed the code around a little and now have the following in the cpp file...
#include "StdAfx.h"
#include "frmRunTimeDataLog.h"
SDUDataLogger::frmRunTimeDataLog::frmRunTimeDataLog(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
but now I get a linker error... it seems I can't win... what is the correct way to declare this and get it to link correctly.. I suppose I could put everything in the header file, but that just doesn't seem like good form...
SDU Data Logger.obj : error LNK2020: unresolved token (06000001) SDUDataLogger.SDUDataLogger.frmRunTimeDataLog::.ctor
C:\Development\Projects\SDU Data Logger\Debug\SDU Data Logger.exe : fatal error LNK1120: 1 unresolved externals
Also, once I get the code to compile and link correctly, how do I get the frmRunTimeDataLog form to be a child of one of the panels contained in the splitContainer? Would it be like
this->runTimeDataLogWindow-> = splitContainer1->Panel1;
For the frmRunTimeDataLog form I configured it so it does not have a title bar or any buttons that would appear on the title bar. Perhaps within Visual Studio C++ Express 2005 a form can't be a child of a panel? I don't know...
Mark

