65,211
社区成员
发帖
与我相关
我的任务
分享
class CSMartLine
{
public:
int xx;
};
class CSMartLines
{
public:
void Add(CSMartLine* pLine);
};
typedef struct SMartLines
{
CSMartLine m_line;
SMartLines* m_NextLine;
}LINES;
void CSMartLines::Add(CSMartLine* pLine)
{
//CSMartLine p = *pLine;
LINES* p = new LINES;
p->m_line = *pLine; //这里不断抛出异常,我不知道为什么? 没有异常呀
p->m_NextLine = NULL;
}
void main()
{
CSMartLine* p= new CSMartLine;
CSMartLines m_SMartLines;
m_SMartLines.Add(p);
system("pause");
}
// My_project.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
using namespace std;
struct CSMartLine
{
int m_data;
};
typedef struct SMartLines
{
CSMartLine m_line;
SMartLines* m_NextLine;
}LINES;
class CSMartLines
{
SMartLines *m_lines;
void Add(CSMartLine* pLine);
};
void CSMartLines::Add(CSMartLine* pLine)
{
LINES* p = new LINES;
p->m_line = *pLine; //这里不断抛出异常,我不知道为什么?
p->m_NextLine = NULL;
if(m_lines == NULL)
{
m_lines = p;
return;
}
LINES* tempLine = m_lines;
while(tempLine->m_NextLine != NULL)
{
tempLine = tempLine->m_NextLine;
}
tempLine->m_NextLine = p;
}
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}