My program keeps giving my undefined references to my vectors and items in namespace fun class driver and i cannot change it I
really need help I'm a pretty big noob at programming

/*
 * Austin Gould
 *
 * main.cpp
 * main to drivers in fun in the sun
 */

#include <iostream>
#include <fstream>
#include <vector>
//#include <process.h>
#include "Clear.h"

namespace fun{

        class func{

              public:
                   static void del();
                   static void make();
                   static void edit( int x );
                   static void rename();
                   static void warning( std::string name, int &x );

              private:

        };

        class driver{

            public:
            	static void getfileinfo( std::string filename, int &x );
            	static int size;
            	static int eff;
            	static int idnumber;
                static std::vector<int> bmv;
                static std::vector<int> amv;
                static std::vector<int> bbv;
                static std::vector<int> abv;

            private:

        };

};

namespace file{

          class del{

			  public:
				  static void deletefile( std::string name ){

                	 std::remove( name.c_str() );

                  }

          };

          class ren{

			  public:
				  static void rename( std::string oldname, std::string name ){

						std::rename( oldname.c_str(), name.c_str() );

			      }

          };

          class open{

			  public:
				  static void openfile( std::string name,
						  std::string dname, int &x ){

					  std::ofstream myf;

					  myf.open( name.c_str() );

					  if( ! myf ){

						  x = 1;

					  }

					  else{

						  myf<< dname << fun::driver::idnumber;

						  x = 0;

					  }

					  myf.close();

					  return;

				  }

          };

};

int main(){

        char c;
        int x = 1;
        char *title = "Drivers For Eng, By: Austin Gould";
        std::string filename = "Filedatainfo(donotdelete).txt";

        clear::title::ctitle( title );

        //_beginthread ( fun::driver::getfileinfo, 0, ( filename, x ) 12 );

        fun::driver::getfileinfo( filename, x );

        while( x != 0 ){

               clear::clr::clearscr();

               std::cout<< "Drivers in class" << std::endl
                        << "[L]ookup drivers" << std::endl
                        << "[C]hange data" << std::endl
                        << "[D]elete a driver" << std::endl
                        << "[M]ake a driver" << std::endl
                        << "[R]ename a driver" << std::endl
                        << "[E]xit" << std::endl
                        << "Input: ";
               std::cin>> c;

               tolower( c );

               if ( c == 'l' ){

            	   x = 2;

                   fun::func::edit( x );

               }

               else if ( c == 'd' ){

                  fun::func::del();

               }

               else if ( c == 'c' ){

                    fun::func::edit( x );

               }

               else if ( c == 'm' ){

                    fun::func::make();

               }

               else if( c == 'r' ){

            	   fun::func::rename();

               }

               else if ( c == 'e' ){

                  x = 0;

                  fun::driver::getfileinfo( filename, x );

               }

               else{

                   std::cout<< std::endl
							<< "Error Input not matched"
							<< std::endl
							<< "Press Enter to Continue..."
							<< std::endl;
                   std::cin.ignore( 1000, '\n' );
                   std::cin.ignore( 1000, '\n' );

               }

        }

    return x;

}

void fun::func::del(){

	clear::clr::clearscr();

	std::string name;
	int x = 3;

	clear::dir::showdir();
	std::cout<< std::endl
			 << "Files in current dir" << std::endl
			 << std::endl;

	std::cout<< "Who would you like to Delete" << std::endl
			 << "Name: ";
	std::cin>> name;

	clear::clr::clearscr();

	fun::func::warning( name, x );

	if ( x == 0 ){

		file::del::deletefile( name );

	}

	else{

		clear::clr::clearscr();

		std::cout<< "The file was not deleted" << std::endl
				 << "Press Enter to Continue..." << std::endl;
		std::cin.ignore();
		std::cin.ignore();

	}

}

void fun::func::edit( int x ){

	std::string name;
	std::string fname;
	std::string edita;

	if( x == 1 ){

		edita = "edit";

	}

	else{

		edita = "lookup";

	}

	clear::clr::clearscr();
	clear::dir::showdir();

	std::cout<< std::endl << "Files in current dir" << std::endl
			 << std::endl << "Who would you like to "<< edita
			 << std::endl << "File Name: " ;
	std::cin>> fname;

	clear::clr::clearscr();

	std::ifstream myf;

	myf.open( fname.c_str(), std::ios::in );

	myf>> name >> driver::idnumber;

	int idnumber = fun::driver::idnumber;

	while( idnumber > 0 ){

		myf>>fun::driver::bbv[idnumber];
		myf>>fun::driver::abv[idnumber];
		myf>>fun::driver::bmv[idnumber];
		myf>>fun::driver::amv[idnumber];
		myf>>fun::driver::eff;

		idnumber--;

	}

	std::cout<< "What day would you like to "<< edita << std::endl
			 << "Current day is Day: " << fun::driver::idnumber
			 << std::endl
			 << "Day: ";
	std::cin>> idnumber;

	if ( x == 1 ){



	}

	else{



	}

}

void fun::func::make(){

	int x = 1;

	clear::clr::clearscr();

    std::string name;
    std::string dname;

    std::cout<< "What would you like the name of the "
			 << "file to be" << std::endl
			 << "File name: ";
    std::cin >> name;

    std::cout<< "What is the drivers name" << std::endl
             << "Name: ";
    std::cin>> dname;

    fun::func::warning( name, x );

    if ( x == 1 ){

    	clear::clr::clearscr();

    	std::cout<< "Error file couldn't be made" << std::endl
				 << "Press Enter to Continue..." << std::endl;
    	std::cin.ignore();
    	std::cin.ignore();

    }

    if ( x == 0 ){

    	file::open::openfile( name, dname, x );

    }

    if( x == 0 ){

    	clear::clr::clearscr();

    	std::cout<< "The file was made successfully" << std::endl
				 << "Press Enter to Continue..." << std::endl;
    	std::cin.ignore();
    	std::cin.ignore();

    }

}

void fun::func::rename(){

	clear::clr::clearscr();

	int x = 2;
	std::string oldname;
	std::string name;

	std::cout<< "What file do you want to rename" << std::endl
			 << "Name: ";
	std::cin >> oldname;

	clear::clr::clearscr();

	std::cout<< "New name: ";
	std::cin >> name;

	clear::clr::clearscr();

	fun::func::warning( oldname, x );

	if( x == 1 ){

		file::ren::rename( oldname, name );

	}

	else{

		clear::clr::clearscr();

		std::cout<< "The file " << oldname
				 << "was not changed" << std::endl;
		std::cin.ignore();

	}

}

void fun::func::warning( std::string name, int &x ){

	char yn;
	std::string item;

	clear::clr::clearscr();

	if ( x == 3 ){

		item = "delete the file ";

	}

	if( x == 2 ){

		item = "rename the file ";

	}

	if ( x == 1 ){

		item = "make the file ";

	}

	std::cout<< "Are you sure you want to " << item
			 << name << std::endl << "( y/n ): ";

	std::cin>> yn;

	tolower( yn );

	if ( yn == 'y' ){

		x = 0;

	}

	else{

		x = 1;

	}

}

void fun::driver::getfileinfo( std::string filename, int &x ){

	if ( x == 1 ){

		std::ifstream myf;

		myf.open( filename.c_str() );

		if( !myf ){

			std::cout<< "Error in creating main file program will now exit"
					 << std::endl
					 << "Press Enter to Continue..." << std::endl;
			std::cin.ignore();
			std::cin.ignore();

			x = 0;

		}

		myf >> size >> idnumber;

		myf.close();

	}

	if ( x == 0 ){

		std::ofstream myf;

		myf.open( filename.c_str(), std::ios::in );

		myf << size << idnumber;

		myf.close();

	}

}

the program is unfinished and anything that refers to clear is part of my clear.h that i have been working on for the past month.

the error list is something like

Description Resource Path Location Type
undefined reference to `fun::driver::abv' main.cpp Drivers in the fun 4 20 270 C/C++ Problem
undefined reference to `fun::driver::amv' main.cpp Drivers in the fun 4 20 272 C/C++ Problem
undefined reference to `fun::driver::bbv' main.cpp Drivers in the fun 4 20 269 C/C++ Problem
undefined reference to `fun::driver::bmv' main.cpp Drivers in the fun 4 20 271 C/C++ Problem
undefined reference to `fun::driver::eff' main.cpp Drivers in the fun 4 20 273 C/C++ Problem
undefined reference to `fun::driver::idnumber' main.cpp Drivers in the fun 4 20 263 C/C++ Problem
undefined reference to `fun::driver::idnumber' main.cpp Drivers in the fun 4 20 265 C/C++ Problem
undefined reference to `fun::driver::idnumber' main.cpp Drivers in the fun 4 20 279 C/C++ Problem
undefined reference to `fun::driver::idnumber' main.cpp Drivers in the fun 4 20 454 C/C++ Problem
undefined reference to `fun::driver::idnumber' main.cpp Drivers in the fun 4 20 466 C/C++ Problem
undefined reference to `fun::driver::size' main.cpp Drivers in the fun 4 20 454 C/C++ Problem
undefined reference to `fun::driver::size' main.cpp Drivers in the fun 4 20 466 C/C++ Problem

Im using eclipse with mingw

Define the static member variables that have been declared.

namespace fun{
        // ...
        class driver{
                // ...
            	static int size;
            	static int eff;
            	static int idnumber;
                static std::vector<int> bmv;
                static std::vector<int> amv;
                static std::vector<int> bbv;
                static std::vector<int> abv;
                // ...
        };
        // ...
}
// ...

int fun::driver::size = 22 ;
int fun::driver::eff = 'F' ;
int fun::driver::idnumber = 77 ;
std::vector<int> fun::driver::bmv ;
std::vector<int> fun::driver::amv( 10U ) ;
std::vector<int> fun::driver::bbv ;
std::vector<int> fun::driver::abv ;

// ...

Sorry but not really what i was looking for i decided to make it into a class and then changed it now though in the getfileinfo function i cannot make my startup file

/*
 * Austin Gould
 *
 * main.cpp
 * main to drivers in fun in the sun
 */

#include <iostream>
#include <fstream>
#include <vector>
#include "Clear.h"

namespace fun{

        class func{

              public:
                   static void del();
                   static void make();
                   static void edit( int x );
                   static void rename();
                   static void warning( std::string name, int &x );

              private:

        };

};

namespace file{

          class del{

			  public:
				  static void deletefile( std::string name ){

                	 std::remove( name.c_str() );

                  }

          };

          class ren{

			  public:
				  static void rename( std::string oldname, std::string name ){

						std::rename( oldname.c_str(), name.c_str() );

			      }

          };

          class open{

			  public:
				  static void openfile( std::string name,
						  std::string dname, int &x ){

					  std::ofstream myf;

					  myf.open( name.c_str() );

					  if( ! myf ){

						  x = 1;

					  }

					  else{

						  myf<< dname;

						  x = 0;

					  }

					  myf.close();

					  return;

				  }

          };

};

class driver{

            public:
            	void getfileinfo( std::string filename, int &x );
            	int size;
            	int eff;
            	int idnumber;
                std::vector<int> bmv;
                std::vector<int> amv;
                std::vector<int> bbv;
                std::vector<int> abv;

            private:

};

int main(){

		driver d;

		char c;
        int x = 1;
        char *title = "Drivers For Eng, By: Austin Gould";
        std::string filename = "Filedatainfodonotdelete.txt";

        clear::settitle::title( title );

        //_beginthread ( fun::driver::getfileinfo, 0, ( filename, x ) 12 );

        d.getfileinfo( filename, x );

        while( x != 0 ){

               clear::clr::clearscr();

               std::cout<< "Drivers in class" << std::endl
                        << "[L]ookup drivers" << std::endl
                        << "[C]hange data" << std::endl
                        << "[D]elete a driver" << std::endl
                        << "[M]ake a driver" << std::endl
                        << "[R]ename a driver" << std::endl
                        << "[E]xit" << std::endl
                        << "Input: ";
               std::cin >> c;

               tolower( c );

               if ( c == 'l' ){

            	   x = 2;

                   fun::func::edit( x );

               }

               else if ( c == 'd' ){

                  fun::func::del();

               }

               else if ( c == 'c' ){

                    fun::func::edit( x );

               }

               else if ( c == 'm' ){

                    fun::func::make();

               }

               else if( c == 'r' ){

            	   fun::func::rename();

               }

               else if ( c == 'e' ){

                  x = 0;

                  d.getfileinfo( filename, x );

               }

               else{

                   std::cout<< std::endl
							<< "Error Input not matched"
							<< std::endl
							<< "Press Enter to Continue..."
							<< std::endl;
                   std::cin.ignore( 1000, '\n' );
                   std::cin.ignore( 1000, '\n' );

               }

        }

    return x;

}

void fun::func::del(){

	clear::clr::clearscr();

	std::string name;
	int x = 3;

	clear::dir::showdir();
	std::cout<< std::endl
			 << "Files in current dir" << std::endl
			 << std::endl;

	std::cout<< "Who would you like to Delete" << std::endl
			 << "Name: ";
	std::cin>> name;

	clear::clr::clearscr();

	fun::func::warning( name, x );

	if ( x == 0 ){

		file::del::deletefile( name );

	}

	else{

		clear::clr::clearscr();

		std::cout<< "The file was not deleted" << std::endl
				 << "Press Enter to Continue..." << std::endl;
		std::cin.ignore();
		std::cin.ignore();

	}

}

void fun::func::edit( int x ){

	driver d;

	std::string name;
	std::string fname;
	std::string edita;

	if( x == 1 ){

		edita = "edit";

	}

	else{

		edita = "lookup";

	}

	clear::clr::clearscr();
	clear::dir::showdir();

	std::cout<< std::endl << "Files in current dir" << std::endl
			 << std::endl << "Who would you like to "<< edita
			 << std::endl << "File Name: " ;
	std::cin>> fname;

	clear::clr::clearscr();

	std::ifstream myf;

	myf.open( fname.c_str(), std::ios::in );

	myf>> name >> d.idnumber;

	int inumber = d.idnumber;

	while( inumber > 0 ){

		myf>> d.bbv[inumber]
		   >> d.abv[inumber]
		   >> d.bmv[inumber]
		   >> d.amv[inumber]
		   >> d.eff;

		inumber--;

	}

	std::cout<< "What day would you like to" << edita << std::endl
			 <<	"[A] to look at all ( only works in lookup )" << std::endl
			 << "Current day is Day: " << d.idnumber
			 << std::endl
			 << "Day: ";
	std::cin>> inumber;

	if ( inumber == 'a' && x != 1 ){

		inumber = d.idnumber;

		clear::clr::clearscr();

		while( inumber > 0 ){

			std::cout<< "Day " << inumber << std::endl
				     << "Before batt. Voltage " << d.bbv[inumber]
				     << std::endl
				     << "After batt. Voltage " << d.abv[inumber]
				     << std::endl
					 << "Before Motor Voltage " << d.bmv[inumber]
				     << std::endl
				     << "After Motor Voltage " << d.amv[inumber]
				     << std::endl << std::endl;

		}

		std::cout<< "Total Eff " << d.eff << std::endl;

	}



	if ( x == 1 ){



	}

	else{

		std::cin.ignore();
		std::cin.ignore();

	}

}

void fun::func::make(){

	int x = 1;
	driver d;

	clear::clr::clearscr();

    std::string name;
    std::string dname;

    std::cout<< "What would you like the name of the "
			 << "file to be" << std::endl
			 << "File name: ";
    std::cin >> name;

    std::cout<< "What is the drivers name" << std::endl
             << "Name: ";
    std::cin>> dname;

    fun::func::warning( name, x );

    if ( x == 1 ){

    	clear::clr::clearscr();

    	std::cout<< "Error file couldn't be made" << std::endl
				 << "Press Enter to Continue..." << std::endl;
    	std::cin.ignore();
    	std::cin.ignore();

    }

    if ( x == 0 ){

    	file::open::openfile( name, dname, x );
    	d.idnumber++;

    }

    if( x == 0 ){

    	clear::clr::clearscr();

    	std::cout<< "The file was made successfully" << std::endl
				 << "Press Enter to Continue..." << std::endl;
    	std::cin.ignore();
    	std::cin.ignore();

    }

}

void fun::func::rename(){

	clear::clr::clearscr();

	int x = 2;
	std::string oldname;
	std::string name;

	std::cout<< "What file do you want to rename" << std::endl
			 << "Name: ";
	std::cin >> oldname;

	clear::clr::clearscr();

	std::cout<< "New name: ";
	std::cin >> name;

	clear::clr::clearscr();

	fun::func::warning( oldname, x );

	if( x == 1 ){

		file::ren::rename( oldname, name );

	}

	else{

		clear::clr::clearscr();

		std::cout<< "The file " << oldname
				 << "was not changed" << std::endl;
		std::cin.ignore();

	}

}

void fun::func::warning( std::string name, int &x ){

	char yn;
	std::string item;

	clear::clr::clearscr();

	if ( x == 3 ){

		item = "delete the file ";

	}

	if( x == 2 ){

		item = "rename the file ";

	}

	if ( x == 1 ){

		item = "make the file ";

	}

	std::cout<< "Are you sure you want to " << item
			 << name << std::endl << "( y/n ): ";

	std::cin>> yn;

	tolower( yn );

	if ( yn == 'y' ){

		x = 0;

	}

	else{

		x = 1;

	}

}

void driver::getfileinfo( std::string filename, int &x ){

	if ( x == 1 ){

		std::ifstream myf;

		myf.open( filename.c_str()//, std::ios::nocreate
				);

		if( !myf ){

			std::cout<< "First run use" << std::endl
					 << "Press Enter to Continue..." << std::endl;
			std::cin.ignore();

			myf.open( filename.c_str() );

		}

		if( !myf ){

			std::cout<< "Error in creating main file program will now exit"
					 << std::endl
					 << "Press Enter to Continue..." << std::endl;
			std::cin.ignore();

			//x = 0;

		}

		myf >> size >> idnumber;

		myf.close();

	}

	if ( x == 0 ){

		std::ofstream myf;

		myf.open( filename.c_str(), std::ios::in );

		myf << size << idnumber;

		myf.close();

	}

}

their are no errors and it compiles into the exe but it willnot make the startup file i had to rem out the x = 0 so my program didn't exit

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.