错误LNK2019:未解析的外部符号_main在函数___tmainCRTStartup中引用 [英] error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
本文介绍了错误LNK2019:未解析的外部符号_main在函数___tmainCRTStartup中引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道发生了什么问题。我找不到错误在哪里,注释的实现也不能解决错误。
I don't know what's wrong with it.. I can't find where the error is, commenting out the implementation doesn't resolve the error either.
头文件
Header File
#ifndef MAIN_SAVITCH_SEQUENCE_H
#define MAIN_SAVITCH_SEQUENCE_H
#include <cstdlib> // Provides size_t
namespace main_savitch_3
{
class sequence
{
public:
// TYPEDEFS and MEMBER CONSTANTS
typedef double value_type;
typedef std::size_t size_type;
static const size_type CAPACITY = 30;
// CONSTRUCTOR
sequence( );
// MODIFICATION MEMBER FUNCTIONS
void start( );
void advance( );
void insert(const value_type& entry);
void attach(const value_type& entry);
void remove_current( );
// CONSTANT MEMBER FUNCTIONS
size_type size( ) const;
bool is_item( ) const;
value_type current( ) const;
private:
value_type data[CAPACITY];
size_type used;
size_type current_index;
};
}
#endif
strong>
Source
#include "sequence1.h"
#include <assert.h>
namespace main_savitch_3
{
// Default constructer - sequence is empty
sequence::sequence()
{
used = current_index = 0;
}
// Start the iteration
void sequence::start()
{
current_index = 0;
}
// Iterate
void sequence::advance()
{
current_index++;
}
// Number of items in the sequence
sequence::size_type sequence::size() const
{
return used;
}
// Checks if there is a current item
bool sequence::is_item() const
{
return current_index <= used && used > 0;
}
// Returns the current value
sequence::value_type sequence::current() const
{
assert(is_item()); // no current item
return data[current_index];
}
// Adds an item BEFORE the current index
void sequence::insert(const value_type& entry)
{
assert(entry != 0); // pointer is invalid
assert(current_index < sequence::CAPACITY); // no room to add an item
// move items up - starting with the last item and working down to the current item
// arrays start at 0, so the -1 adjusts it
for (size_type i = used - 1; i >= current_index; i--)
data[i + 1] = data[i];
data[current_index] = entry;
}
// Adds an item AFTER the current index
void sequence::attach(const value_type& entry)
{
assert(entry != 0); // pointer is invalid
assert(current_index < sequence::CAPACITY); // no room to add an item
// move items up - starting with the last item and working down to the current item
// arrays start at 0, so the -1 adjusts it
for (size_type i = used - 1; i > current_index; i--)
data[i + 1] = data[i];
if (current_index = 0)
data[used] = entry;
else
data[current_index + 1] = entry;
}
// Removes the current item
void sequence::remove_current()
{
for (size_type i = current_index; i < used; i++)
data[i] = data[i + 1];
}
}
推荐答案
即使你的项目有一个 main()
方法,链接器有时会感到困惑。你可以在Visual Studio 2010中通过转到
Even if your project has a main()
method, the linker sometimes gets confused. You can solve this issue in Visual Studio 2010 by going to
项目 - >属性 - >配置属性 - >链接器 - >系统
Project -> Properties -> Configuration Properties -> Linker -> System
并将 SubSystem
更改为控制台。
这篇关于错误LNK2019:未解析的外部符号_main在函数___tmainCRTStartup中引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文