+ -
当前位置:首页 → 问答吧 → 帮忙看看一段代码,想调试看看this指针

帮忙看看一段代码,想调试看看this指针

时间:2011-11-25

来源:互联网

#include <iostream>

class screen
{
public:
typedef std::string::size_type index;
private:
std::string contents;
index cursor;
index height,width;
public:
screen &move(index r,index c);
screen &set(char);
screen &set(index,index,char);
};
screen &screen::set(char c)
{
contents[cursor] = c;
return *this;
}
screen &screen::move(index r,index c)
{
index row=r*width;
cursor =row+c;
return *this;
}
-------------------------------------------------------------------------



IBCD.lib(crt0.obj) : error LNK2019: 无法解析的外部符号 _main ,该符号在函数 _mainCRTStartup 中被引用
Debug/aa.exe : fatal error LNK1120: 1 个无法解析的外部命令

作者: caixucxcxforever   发布时间: 2011-11-25

啥意思?这是整个工程?
入口呢?

作者: lgstudyvc   发布时间: 2011-11-25

要么你是没有main函数?
要么你是Window程序但是设置system => subsystem =>Console (/SUBSYSTEM:CONSOLE)函数?

作者: yuucyf   发布时间: 2011-11-25

C/C++ code
建立的是控制台程序,需要main函数的
改为
#include <iostream>

class screen
{
public:
typedef std::string::size_type index;    
private:
std::string contents;
index cursor;
index height,width;
public:
screen &move(index r,index c);
screen &set(char);
screen &set(index,index,char);
};
screen &screen::set(char c)
{
contents[cursor] = c;
return *this;
}
screen &screen::move(index r,index c)
{
index row=r*width;
cursor =row+c;
return *this;
}

//增加main函数
int main(void)
{
   screen sc;
 ....其他
  
 return 0;
}

作者: gameslq   发布时间: 2011-11-25

没有入口函数,你的main函数呢

作者: VisualEleven   发布时间: 2011-11-25

引用 2 楼 yuucyf 的回复:

要么你是没有main函数?
要么你是Window程序但是设置system => subsystem =>Console (/SUBSYSTEM:CONSOLE)函数?


main 函数是必须的吗?
我看过一些 根本不用main函数都能调试通过啊。。。。
我只是想看看this指针 里面的值 到底是多少。。。

作者: caixucxcxforever   发布时间: 2011-11-25

引用 3 楼 gameslq 的回复:

C/C++ code
建立的是控制台程序,需要main函数的
改为
#include <iostream>

class screen
{
public:
typedef std::string::size_type index;
private:
std::string contents;
index cursor;
index height,width;
public:
scree……



main 函数是必须的吗? 加上main 函数确实调试过了

作者: caixucxcxforever   发布时间: 2011-11-25

引用 5 楼 caixucxcxforever 的回复:
引用 2 楼 yuucyf 的回复:

要么你是没有main函数?
要么你是Window程序但是设置system => subsystem =>Console (/SUBSYSTEM:CONSOLE)函数?


main 函数是必须的吗?
我看过一些 根本不用main函数都能调试通过啊。。。。
我只是想看看this指针 里面的值 到底是多少。。。

控制台程序当然要有main函数啦。

作者: yuucyf   发布时间: 2011-11-25

引用 6 楼 caixucxcxforever 的回复:

引用 3 楼 gameslq 的回复:

C/C++ code
建立的是控制台程序,需要main函数的
改为
#include <iostream>

class screen
{
public:
typedef std::string::size_type index;
private:
std::string contents;
index cursor;
ind……




哪些地方用main函数 哪些地方可以不用main函数???请将

作者: caixucxcxforever   发布时间: 2011-11-25

还没碰到哪里不要入口函数的。
main和winmain,UNICODE下和多字节下名字稍有不同,MFC里winmain被封装了,其实还是有调用到的

作者: dahaiI0   发布时间: 2011-11-25

哪些地方用main函数 哪些地方可以不用main函数???请将
============
C++/C语言程序一般情况下一定要用入口函数,对于控制台程序入口函数是main,对于窗口应用程序是WinMain函数。
其实确实也有不用main函数的情况。入口点函数只是编译器设置的一个规定,程序总得有一个开始执行的位置。比如你不写main函数,直接定义一个mainCRTStartup函数也是可以的。

作者: wltg2001   发布时间: 2011-11-25