LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   error: unresolved external symbol (https://www.linuxquestions.org/questions/programming-9/error-unresolved-external-symbol-306166/)

purefan 03-25-2005 11:40 PM

error: unresolved external symbol
 
hello!
well im writting a Wallet program, basically (as it is) the user is suposed to be able to add expenses, incomes (both with comments) and the program keeps a record of when you spent and how much and in what. It is a self proyect, just for the love to art ;)
Please remember that not all the functions are complete since im stuck with the storing to char[] ProfileInUse
Im using VC++6 under Windows XP Professional.
The linker returns:
Contador.obj : error LNK2001: unresolved external symbol "private: static char * Wallet::ProfileInUse" (?ProfileInUse@Wallet@@0PADA)
I read the MSDN about the number of the problem but was not able to solve this issue...:cry:
well here is the code:
Code:

// Wallet.cpp
#include "contador.h"
#include <stdlib.h>
#include <stdio.h>

int main()
{
Wallet::Menu();
        return 0;
}

// EOF Wallet.cpp

Code:

// Wallet.h
#include <fstream.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <windows.h>

/*
Menu options and 'manual':
1. First user must create a profile
2. User must open a profile
3. User can add expenses, incomes, show balance
4. User can exit the program (it closes the profile/session by itself)

        -Creation of a Profile
                The program creates a file
        - Opening of a profile
                Opens the respective file and adds to InUse[] the name of the profile being used
        - Adding of information
                Knowing which profile is being used the program adds +INTEGER/COMMENT/ or -INTEGER/COMMENT/
 


*/


class Wallet
{

        public:
                static void Create_Profile(char b[]);       
                static void Erase_Profile(char c[]);

                void CerrarProfile();               
                void AddExpense(int);               
                void AddIncome(int);       
                void ShowBalance();       
                void CalculateBalance();
                void OpenProfile();       
                static void Menu();
               

        private:
                int Incomes[50];
                static char ProfileInUse[20];


};

void Wallet::Create_Profile(char a[])
{
        WIN32_FIND_DATA FindFileData;
        HANDLE hFind;
        system("cls");
        printf ("Checking for duplication of file:  %s.\n", a);
        hFind = FindFirstFile(a, &FindFileData);
        if (hFind == INVALID_HANDLE_VALUE)
  {
         
          cout << "The profile does not exist yet.\nProceeding to create it:\n";
          ofstream Profile(a);
          Profile.close();
          cout << "....\nProfile succesfully created!\n\n";


  }
  else
  {
          cout << "Imposible to create the new profile, Name already exists.\n";
      FindClose(hFind);
 
  }

}



void Wallet::Erase_Profile(char c[])
{

system("cls");
cout << "You are about to delete " << c << ".\nContinue?\n";
char question1;
cout << "Enter 'y' for yes | Enter 'n' for No";
cin >> question1;
if (question1 == 's')
        {
                if ( remove(c) == -1)
                        perror ("\nA problem occured and the profile was NOT deleted\n");
                else ( puts("\nProfile succesfully deleted\n"));
        }

}//Wallet::Erase_Profile

void Wallet::Menu()
{
//        system("cls");

                for (int i = 0; i < 20; i++){
                        ProfileInUse[i] = '\0';
                }

        cout << "\t-Menu-\n";
        cout << "1.Open Profile\n";
        cout << "2.Create Profile\n3.Erase Profile\n";

int Men;
cin >> Men;

switch(Men)
        {
case 1:
        cout << "Enter the name of the profile";

Here is "where" the problem occurs:
Code:

cin >> ProfileInUse;
       
        break;
case 2: char Name[10];
                cout << "Create Profile.\n Write a Name for the new profile (10 characters max)\n";
                cin.getline(Name,10);// >> Name;
                //cin.getline(Name,10);
                Wallet::Create_Profile(Name);
                Wallet::Menu();
                break;
case 3:char NameErase[10];
        cout << "What profile do you wish to Erase?\n";
        cin.getline(NameErase,10);// >> NameErase;
        //cin.getline(NameErase,10);
        Wallet::Erase_Profile(NameErase);
        Wallet::Menu();
        break;
        }//switch

}// EOF wallet.h

Any idea of what the problem actually is?? how to fix it???
Anyway thanks for taking the time :)

ahwkong 03-26-2005 02:42 AM

Add this line to wallet.cpp

char Wallet::ProfileInUse[20] = "";

You can initialise it to anything you like, actually.

purefan 03-26-2005 07:10 AM

YAAAHOOO!!!!! (or google if you prefer)
Thanks!!! =D
believe it or not I had spent just about one week trying to get this right...I feel dumb
anyways it worked. thanks a lot! :D

ahwkong 03-26-2005 07:27 AM

No worries.


All times are GMT -5. The time now is 06:57 AM.