错误:未解析的外部符号 [英] Error: Unresolved external Symbol

查看:73
本文介绍了错误:未解析的外部符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在编写一段代码.我需要从一个在另一个类中声明的类访问变量.

例如:

Hello there,

I''m working on a piece of code. I need to access a variable from one class which is declared in another one.

For Example:

Class Sum
{
double time;
}

class Calc
{
static Sum ss; // reference to the Sum class
}

class Settings :: setup()
{
Calc:: ss.time 
}



为了获得该变量,我必须使sum成为静态,但是却收到一条错误消息,指出未解决的外部符号



I had to make sum static in order to aceess the variable but I get an error that says Unresolved external Symbol

public: static class Sum Geo::ss" (?ss@Geo.....bla bla)

推荐答案

static变量必须在源文件中定义(您仅提供了声明).例如,将变量定义放在class Calc 源文件(例如" calc.cpp ")中:
static variables must defined in a source file (you provided only the declaration). Put, for instance, in the class Calc source file (say "calc.cpp") the variable definition:
Sum Calc::ss;


这篇关于错误:未解析的外部符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆