I'm haveing trouble with this program I don't know what the problem is because my compiler says that their isn't one but the console says their is but it wont give me lines my code is very long too.

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

namespace fun{

        class func{

              public:
                   static void del();
                   static void make();
                   static void edit();
                   static void lookup();
                   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();

				  }

          };

};

class driver{

            public:
            	void mainfile();
            	void loadmainfile( int &x );
            	void savemainfile();
            	void loaddata( std::string name, int &x );
            	void savedata( std::string name, std::string
							    dname, int &x );
            	void geteff();
            	int idnumber;
            	int midnumber;
            	int trackl;
            	std::string dname;
            	std::vector<std::string> names;
            	//std::string names;
                std::vector<int> bmv;
                std::vector<int> amv;
                std::vector<int> bbv;
                std::vector<int> abv;
                std::vector<int> eff;

};

int main(){

		driver d;

		char *title = "Drivers For Eng, By: Austin Gould";
		char c;
        int x = 1;

        while( x != 0 ){

			   title = "Drivers For Eng, By: Austin Gould";
			   clear::settitle::title( title );

               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
                        << "[X] Edit main" << std::endl
                        << "[E]xit" << std::endl
                        << "Input: ";
               std::cin >> c;

               tolower( c );

               if ( c == 'l' ){

            	   title = "Lookup Drivers";

            	   clear::settitle::title( title );

                   fun::func::lookup();

               }

               else if ( c == 'd' ){

            	  title = "Delete a Driver";

            	  clear::settitle::title( title );

                  fun::func::del();

               }

               else if ( c == 'c' ){

            	   title = "Edit Drivers";

            	   clear::settitle::title( title );

                   fun::func::edit();

               }

               else if ( c == 'm' ){

            	   title = "Make a Driver";

            	   clear::settitle::title( title );

                   fun::func::make();

               }

               else if( c == 'r' ){

            	   title = "Rename a Driver";

            	   clear::settitle::title( title );

            	   fun::func::rename();

               }

               else if ( c == 'e' ){

                  x = 0;

               }

               else if ( c == 'x' ){

            	   title = "Main File Edit";

            	   clear::settitle::title( title );

            	   d.mainfile();

               }

               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;
	std::string fileext = ".txt";
	int x = 3;
	driver d;

	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 ){

		name = name + fileext;

		file::del::deletefile( name );

		x = 3;

	}

	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(){

	driver d;

	std::string name;
	std::string fileext = ".txt";
	int x = 0;
	int h = 0;
	char c = ' ';

	clear::clr::clearscr();

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

	name = name + fileext;

	d.loaddata( name, x );

	if( x == 1 ){

		std::cout<< "File was not found" << std::endl
				 << "Press Enter to Continue..." << std::endl;
		std::cin.ignore();

	}

	while ( x != 1 ){

		clear::clr::clearscr();

		std::cout<< "Would you like do to "
				 << name << std::endl
				 << "[A]dd a day" << std::endl
				 << "[C]hange a day" << std::endl
				 << "[D]elte a day" << std::endl
				 << "[E]xit" << std::endl;
		std::cin >> c;

		clear::clr::clearscr();

		if( c == 'a' ){

			d.bbv.push_back( 1 );
			d.abv.push_back( 1 );
			d.bmv.push_back( 1 );
			d.amv.push_back( 1 );

			d.idnumber++;

			h = d.bbv.size();

			while( c != 'g' ){

				clear::clr::clearscr();

				std::cout<< "Before Batt. Voltage: ";
				std::cin >> d.bbv[h];
				std::cout<< "After Batt. Voltage: ";
				std::cin >> d.abv[h];
				std::cout<< "Before Motor Voltage: ";
				std::cin >> d.bmv[h];
				std::cout<< "After Motor Voltage: ";
				std::cin >> d.amv[h];

				std::cout<< std::endl << "[G]ood?"
						 << std::endl;
				std::cin>> c;

			}

			x = 2;

			d.savedata( name, d.dname, x );

		}

		else if( c == 'e' ){

			x = 1;

		}

		else if( c == 'c' ){



		}

		else if( c == 'd' ){



		}

		else{

			std::cout<< "Input unmatched" << std::endl
					 << "Press Enter to Continue...";
			std::cin.ignore();
			std::cin.ignore();

		}

	}

	return;

}

void fun::func::lookup(){

	driver d;

	int x;
	std::string name;
	std::string fileext = ".txt";

	clear::clr::clearscr();

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

	name = name + fileext;

	d.loaddata( name, x );

	if ( x != 1 ){

		clear::clr::clearscr();

		//std::cout<< x << std::endl;
		//std::cin.ignore();
		//std::cin.ignore();

		x = d.bbv.size();

		clear::clr::clearscr();

		while ( x != 0 ){

			std::cout<< "Day: " << x
					 << std::endl
					 << "Before Batt. Voltage: " << d.bbv[x]
					 << std::endl
					 << "After Batt. Voltage: " << d.abv[x]
					 << std::endl
					 << "Before Motor Voltage: " << d.bmv[x]
					 << std::endl
					 << "After Motor voltage: " << d.amv[x]
	                 << std::endl
					 << "Eff: " << d.eff
					 << std::endl << std::endl;

			x--;

		}

		x = 1;

		std::cout<< std::endl << std::endl
				 << "Press enter to Continue..."
				 << std::endl;
		std::cin.ignore();
		std::cin.ignore();

	}

	return;

}

void fun::func::make(){

	int x = 1;
	driver d;

	clear::clr::clearscr();

    std::string name;
    std::string dname;
    std::string fileext = ".txt";

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

    clear::clr::clearscr();

    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 ){

    	name = name + fileext;

    	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();

    	d.savedata( name, dname, x );

    }

}

void fun::func::rename(){

	clear::clr::clearscr();

	int x = 2;
	std::string fileext = ".txt";
	std::string oldname;
	std::string name;

	clear::dir::showdir();

	std::cout<< std::endl << "Files in current dir"
			 << std::endl << std::endl
			 << "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 ){

		name = name + fileext;

		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::loaddata( std::string name, int &x ){

	std::ifstream myf;

	myf.open( name.c_str() );

	if( !myf ){

		//clear::clr::clearscr();

		x = 1;

		return;

	}

	myf>> dname >> idnumber;

	x = idnumber;

	while( x != 0 ){

		this->bbv.push_back( x );
	    this->abv.push_back( x );
	    this->bmv.push_back( x );
	    this->amv.push_back( x );

		myf >> this->bbv[x]
		    >> this->abv[x]
		    >> this->bmv[x]
		    >> this->amv[x]
			>> this->eff[x];

		x--;

	}

	myf.close();


}

void driver::savedata( std::string name, std::string dname, int &x ){

	std::ofstream myf;

	myf.open( name.c_str(), std::ios::out );

	if( x == 0 ){

	    this->idnumber = 0;

		myf << dname
			<< this->idnumber
			<< this->bbv[x]
		    << this->abv[x]
		    << this->bmv[x]
		    << this->amv[x]
		    << this->eff[x];

		myf.close();


	}

	if ( x == 2 ){

		x = bbv.size();

		myf << dname
			<< idnumber;

		while( x != 0 ){

			myf << bbv[x]
			    << abv[x]
			    << bmv[x]
			    << amv[x]
				<< eff[x];

			x--;

		}

	}

	myf.close();

}

void driver::mainfile(){

	int x = 0;

	clear::clr::clearscr();

	loadmainfile( x );

	if ( x == 1 ){

		std::cout<< "File Not Found" << std::endl;
		clear::cpause::pause();

		return;

	}

	else{

		while( x != 1 ){

			clear::clr::clearscr();

			std::cout<< "What do you want to do to the main file" << std::endl
					 << "[T]rack edit" << std::endl
					 << "[D]elete or edit a person in file" << std::endl
					 << "[E]xit" << std::endl
					 << "Input: ";
			std::cin >> x;

			if ( x == 't' ){

				clear::clr::clearscr();

				std::cout<< "What do you want the new track length to be" << std::endl
						 << "New Length: ";
				std::cin >> trackl;

				savemainfile();

			}

			else if ( x == 'e' ){

				x = 1;

			}

		}

	}

}

void driver::savemainfile(){

	std::ifstream myf;

	std::string filename = "Donotdelete.txt";

	myf.open( filename.c_str() );

	if ( !myf ){

		clear::clr::clearscr();

		std::cout<< "File couldn't be found" << std::endl;

		clear::cpause::pause();

	}

	else{

		myf >> midnumber
		    >> trackl;

		while( midnumber != 0 ){

			myf >> names[midnumber];

			midnumber--;
		}

	}

}

void driver::loadmainfile( int &x ){

	std::ofstream myf;

	std::string filename = "Donotdelete.txt";

	myf.open( filename.c_str() );

	if( !myf ){

		x = 1;

	}

	else{

		myf << midnumber
			<< trackl;

		x = midnumber;

		while( x != 0 ){

			myf << names[x];

			x--;

		}

	}

}

here is the error text

**** Build of configuration Debug for project Drivers in the fun 4 20 ****

**** Internal Builder is used for build ****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -omain.o ..\main.cpp
..\main.cpp: In static member function `static void fun::func::lookup()':
..\main.cpp:428: error: no match for 'operator<<' in 'std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::char_traits<char> >&)(+(+(+std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::char_traits<char> >&)(+(+(+std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::char_traits<char> >&)(+(+(+std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::char_traits<char> >&)(+(+(+std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::char_traits<char> >&)(+(+(+std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::char_traits<char> >&)(&std::cout)), ((const char*)"Day: ")))->std::basic_ostream<_CharT, _Traits>::operator<< [with _CharT = char, _Traits = std::char_traits<char>](x))->std::basic_ostream<_CharT, _Traits>::operator<< [with _CharT = char, _Traits = std::char_traits<char>](std::endl [with _CharT = char, _Traits = std::char_traits<char>]))), ((const char*)"Before Batt. Voltage: ")))->std::basic_ostream<_CharT, _Traits>::operator<< [with _CharT = char, _Traits = std::char_traits<char>]((((std::vector<int, std::allocator<int> >*)(&d)) + 52u)->std::vector<_Tp, _Alloc>::operator[] [with _Tp = int, _Alloc = std::allocator<int>](((unsigned int)x))))->std::basic_ostream<_CharT, _Traits>::operator<< [with _CharT = char, _Traits = std::char_traits<char>](std::endl [with _CharT = char, _Traits = std::char_traits<char>]))), ((const char*)"After Batt. Voltage: ")))->std::basic_ostream<_CharT, _Traits>::operator<< [with _CharT = char, _Traits = std::char_traits<char>]((((std::vector<int, std::allocator<int> >*)(&d)) + 64u)->std::vector<_Tp, _Alloc>::operator[] [with _Tp = int, _Alloc = std::allocator<int>](((unsigned int)x))))->std::basic_ostream<_CharT, _Traits>::operator<< [with _CharT = char, _Traits = std::char_traits<char>](std::endl [with _CharT = char, _Traits = std::char_traits<char>]))), ((const char*)"Before Motor Voltage: ")))->std::basic_ostream<_CharT, _Traits>::operator<< [with _CharT = char, _Traits = std::char_traits<char>]((((std::vector<int, std::allocator<int> >*)(&d)) + 28u)->std::vector<_Tp, _Alloc>::operator[] [with _Tp = int, _Alloc = std::allocator<int>](((unsigned int)x))))->std::basic_ostream<_CharT, _Traits>::operator<< [with _CharT = char, _Traits = std::char_traits<char>](std::endl [with _CharT = char, _Traits = std::char_traits<char>]))), ((const char*)"After Motor voltage: ")))->std::basic_ostream<_CharT, _Traits>::operator<< [with _CharT = char, _Traits = std::char_traits<char>]((((std::vector<int, std::allocator<int> >*)(&d)) + 40u)->std::vector<_Tp, _Alloc>::operator[] [with _Tp = int, _Alloc = std::allocator<int>](((unsigned int)x))))->std::basic_ostream<_CharT, _Traits>::operator<< [with _CharT = char, _Traits = std::char_traits<char>](std::endl [with _CharT = char, _Traits = std::char_traits<char>]))), ((const char*)"Eff: ")) << d.driver::eff'
E:/Eclipse Cpp/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/ostream.tcc:63: note: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>&(*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
E:/Eclipse Cpp/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/ostream.tcc:74: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ios<_CharT, _Traits>&(*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
E:/Eclipse Cpp/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/ostream.tcc:86: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base&(*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]
E:/Eclipse Cpp/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/ostream.tcc:121: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits<char>]
E:/Eclipse Cpp/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/ostream.tcc:155: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
E:/Eclipse Cpp/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/ostream.tcc:98: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits<char>]
E:/Eclipse Cpp/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/ostream:178: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits<char>]
E:/Eclipse Cpp/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/ostream:189: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
E:/Eclipse Cpp/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/ostream:193: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>]
E:/Eclipse Cpp/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/ostream:204: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
E:/Eclipse Cpp/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/ostream.tcc:179: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>]
E:/Eclipse Cpp/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/ostream.tcc:214: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
E:/Eclipse Cpp/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/ostream.tcc:238: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits<char>]
E:/Eclipse Cpp/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/ostream:219: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits<char>]
E:/Eclipse Cpp/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/ostream.tcc:261: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits<char>]
E:/Eclipse Cpp/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/ostream.tcc:284: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits<char>]
E:/Eclipse Cpp/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/ostream.tcc:307: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<char>]
Build error occurred, build is stopped
Time consumed: 10970 ms.


end error

clear.h and the namepsace clear is my header and namepsace
their is nothing wrong with it either just a problem somewhere
in their

also im not asking you to rewrite it and it is an unfinised project
but the point is to save a person or driver to a file for our
electric car team and then get his or her eff off the data

thanks in advance

Please try to replicate the problem in as few lines as possible - I'm guessing you can start paring down the code and get it to < 20 lines to produce the same problem. This process will probably magically point out the problem! If it doesn't, then we'd be happy to help.

Dave

commented: That's for sure :) +1

Ok the problem is one and only one line.

The first is that you are compiling -O3 ... until you have got all the compilation errors out and debugged it DONT use -O anything!

Second the error is on line 428

<< "After Motor voltage: " << d.amv[x]
	       << std::endl
	       << "Eff: " << d.eff                // ERROR HERE
	       << std::endl << std::endl;

The reason is that d.eff is a vector<int> and you don't have an operator<< for the vector.

You might like to write it out with this

copy(d.eff.begin(0,d.eff.end(),std::ostream_iterator<int>(std::cout,","));
std::cout<<std::endl;

but there are other ways.

The output from g++ will tell you the error BUT you have to start with the first line of the error. It often helps to pipe the output into a file and read it with no line wrap eg. [in Linux/Unix bash shell]

g++ test.cpp 2> error.txt
vim error.txt
:set nowrap

the set nowrap command is given in vim but your favourite editor will be equally suitable.

Thanks sorry the error was so long yeah I forgot that eff was a vector because befor is was only an int and I wasn't pointing in that array.

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.