0

My program compiles, but I get the following link errors:

1>desalter.obj : error LNK2020: unresolved token (0A000065) "private: static double (* DataBace::Number_d_save)[110]" (?Number_d_save@DataBace@@$$Q0PAY0GO@NA)
1>desalter.obj : error LNK2020: unresolved token (0A000066) "private: static double (* DataBace::Flow_spec)[5]" (?Flow_spec@DataBace@@$$Q0PAY04NA)
1>desalter.obj : error LNK2020: unresolved token (0A000068) "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * DataBace::Flow_Name" (?Flow_Name@DataBace@@$$Q0PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)
1>desalter.obj : error LNK2001: unresolved external symbol "private: static double (* DataBace::Flow_spec)[5]" (?Flow_spec@DataBace@@$$Q0PAY04NA)
1>desalter.obj : error LNK2001: unresolved external symbol "private: static double (* DataBace::Number_d_save)[110]" (?Number_d_save@DataBace@@$$Q0PAY0GO@NA)
1>desalter.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * DataBace::Flow_Name" (?Flow_Name@DataBace@@$$Q0PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)
1>C:\Users\Mojtaba Mohayeji\Documents\Visual Studio 2010\Projects\desalter\Debug\desalter.exe : fatal error LNK1120: 6 unresolved externals

Code:

class DataBace
{
public:

//---
void fLOW_NAME(int indicator, string flow_name)
{
    Flow_Name[indicator] = flow_name;
}
string** fLOW_NAME_READ()
{
    string** flow_name_read = new string*[1];
    for (int i = 1; i < 100; i++)
    {
        string a = Flow_Name[i];
        flow_name_read[i] = &a;
    }
    return flow_name_read;
}
int Show(string show)
{
    for (int i = 0; i < 100; i++)
    {
        string sh = Flow_Name[i];
        if (sh==show)
        {
            return i;
        }
    }
}
void FLOW_SPEC(int indicator, double flow_spec[1][5])
{
    for (int i = 0; i < 5; i++)
    {
        Flow_spec[indicator][i] = flow_spec[1][i];
    }
}
double** FLOW_SPEC_READ(int SHOW)
{
    double** flow_spec_read = new double*[5];
    for (int i = 1; i < 5; i++)
    {
        double a = Flow_spec[SHOW][i];
        flow_spec_read[i] = &a;
    }
    return flow_spec_read;
}
void Number_d_SAVE(int indicator, double Number_d[110])
{
    for (int i = 0; i < 110; i++)
    {
        Number_d_save[indicator][i] = Number_d[i];
    }
}
double** Number_d_READ(int SHOW)
{
    double** Number_d_read = new double*[110];
    for (int i = 1; i < 110; i++)
    {
        double a = Number_d_save[SHOW][i];
        Number_d_read[i] = &a;
    }
    return Number_d_read;
}
private:
    static string Flow_Name[100];
    static double Flow_spec[100][5];
    static double Number_d_save[100][110];

};
MuertoExcobito
  • 9,741
  • 2
  • 37
  • 78
mojtaba
  • 31
  • 1
  • 5
  • Where do you call these functions – Khurram Sharif Jun 10 '15 at 18:23
  • i call it in: private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) – mojtaba Jun 10 '15 at 18:30
  • possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Ken White Jun 10 '15 at 18:50
  • 1
    In exactly one .cpp file, write `string DataBace::Flow_Name[100];`, and similarly for other static members. Static members need to be declared in-class (as you did), and also defined out of class (as you did not). – Igor Tandetnik Jun 10 '15 at 19:12
  • thanks every body for help. Igor solve my problem. – mojtaba Jun 11 '15 at 06:36

0 Answers0