Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


wabbz111

Member Since 30 Aug 2007
Offline Last Active Mar 19 2015 12:42 AM

Topics I've Started

C++ do while error

18 March 2015 - 04:17 AM

Hi i have an issue with this block of code even though all my braces have been opened and closed. Can someone please help out? Regards

expected unqualified-id before 'do'
expected '}' at end of input
expected unqualified-id at end of input

#include<cstdlib>
#include<iostream>
#include<string>
using namespace std;

class President
{
    public:
           
        //int ca=0,cb=0,cc=0,tv=0;
        //string sa="Wamalwa",sb="Rotich",sc="Fatima";
        
        int ca,cb,cc,tv;
        string sa,sb,sc;
         char pchoice,pchoice2;
         
        
        void PWinner()
        {
            if (ca > cb && ca > cc)
               {
                  cout<< "and the winner is : Wamalwa" << endl;
               }
           else if (cb > ca && cb > cc)
               {
                  cout << "and the winner is : Rotich" << endl;
               }
           else if (cc > ca && cc > cb)
                  cout << "and the winner is : Fatima" << endl;
           else
                  cout << "no winning president go for a runoff" << endl;

        }

     //my error is here
      do
      {
        void PMenu()
        {
                  cout<<"\t Presidential Elections\n\n";
               cout<<"Candidates \n\n";
               cout<<"<A>Wamalwa \n";
               cout<<"<B>Rotich \n";
               cout<<"<C>Fatima \n\n";
               cout<<"Pick a candidate\n";
               cin>>pchoice;
        switch(pchoice)
         {
            case 'A':
            case 'a':
                ca++;
                break;
            case 'B':
            case 'b':
                cb++;
                break;
            case 'C':
            case 'c':
                cc++;
                break;
            
        }
       while(pchoice2=='V' || pchoice2=='v');
}
       if (pchoice2=='R' || pchoice2=='r')
       {
            cout<<"\t Chairman Elections\n\n";
            cout<<"Candidates:"<<"\t results:"<<"\n\n";
            cout<<"<A>Wamalwa : "<<ca<<"\n";
            cout<<"<B>Rotich : "<<cb<<"\n";
            cout<<"<C>Fatima : "<<cc<<"\n\n";
            tv=ca+cb+cc;
            cout<<"Total Votes : "<<tv<<"\n";
       }
    
    //private:
 
}
};
/*
class Senator
{
    public:
        //int pa=0,pb=0,pc=0,sv=0;
        //string xa="Mona", xb="Nyachae", xc="Nzuki";
        
        void SWinner()
        {
                
  //for senators
     if (pa > pb && pa > pc)
    {
        cout<< "and the winner is : roto" << endl;
    }
    else if (pb > pa && pb > pc)
    {
        cout << "and the winner is : maish" << endl;
    }
    else if (pc > pa && pc > pb)
    {
        cout << "and the winner is : maish" << endl;
    }
    else
        cout << "no winning senator go for a runoff" << endl;
            
        }
        
        void SMenu()
        {
                cout<<"\t senators Elections\n\n";
    cout<<"Candidates \n\n";
    cout<<"<D>Mona\n";
    cout<<"<E>Nyachae\n";
    cout<<"<F>Nzuki\n\n";
    cout<<"Enter your vote : ";
    cin>>choice;
    
    //for senators
    case 'D':
    case 'd':
        pa++;
        break;
    case 'E':
    case 'e':
        pb++;
        break;
    case 'F':
    case 'f':
        pc++;
        break;
        }
    cout<<"-----------------------\n";
    cout<<"Enter <v>vote <r> result and <q> quit : ";
    cin>>schoice2;
   // private:
};*/
int main()
{
    
   

    //for senaors
    //char Schoice, Sechoice;

  President Wamalwa;

  Wamalwa.PMenu();

  Wamalwa.PWinner();

//    do
//{



//    }

    
    //}
    
    /*///////senators
    cout<<"\t Secretary Elections\n\n";
    cout<<"Candidates \n\n";
    cout<<"<D>Mona"<<pa<<"\n";
    cout<<"<E>Nyachae "<<pb<<"\n";
    cout<<"<F>Nzuki "<<pc<<"\n";
    cout<<"Enter your vote : ";*/
    
    //sv=pa+pb+pc;
    
    //}

        
        
        system("pause");
        return 0;
}


 


c++ friend classes

04 March 2015 - 02:38 AM

I am having issues trying to use friend classes. I want the class Porsche to use method Steer() found in vehicle class but i have tried several styles without success could someone point me in the right direction.
With the class Lamborghini i used inheritance and it works fine but i wanted to use friend classes for the Porsche class. My code is below
 Thanks
 




<code>
#include <cstdlib>
#include <iostream>

using namespace std;



class Vehicle
{

public:
    friend class Porsche; //porsche as friend to vehicle
    void Steer()
    {
      vLeft = "steering left";
      vRight = "steering right";
       
      
     // if (vLeft)
		cout <<vLeft<< endl;
	  //if(steering Right)
		cout << vRight << endl;  
        //cout
    }
   int Accelerate()
    {
        vAcceleration = 5.0f;
        cout<<"acceleration takes "<<vAcceleration<<" seconds "<<endl;
        return vAcceleration;
    }
    int Brake()
    {
       
        cout<<"Brakes applied"<< vBrake<<endl;
        
    }
private:
    float vAcceleration;
    string vBrake;
    int vTopSpeed;
    string vLeft;
    string vRight;
     //declare porsche as friend to vehicle
    
};

class Porsche
{
    
    public:
     friend class Vehicle; //declare vehicle as friend to porsche
     string pName;
     int PorscheAccelerate()
        {
            cout<<" Porsche accelerates in "<<pAcceleration<<" seconds "<<endl;
        }
     int PorscheTopSpeed()
        {
            pTopSpeed = 350;
            cout<<" Porsche Cayenne has a top speed of "<<pTopSpeed<<" KM/H "<<endl;
        }
    int PorscheHorsePower()
        {
            pHorsePower=460;
            cout<<" Porsche produces "<<pHorsePower<<endl;
        }
  //* 
   void PorscheSteer(Vehicle porsche)
    {
       // Steer();
    }//*/
    private:
        float pAcceleration;
        string pBrake;
        int pTopSpeed;
        int pHorsePower;
       
    
};

class Lamborghini : public Vehicle
{
    public:
     string LamboName;
     int LamboAccelerate()
        {
            cout<<" Lamborghini accelerates in "<<lAcceleration<<" seconds "<<endl;
        }
     int LamboTopSpeed()
        {
            lTopSpeed = 440;
            cout<<" Lamborghini has a top speed of "<<lTopSpeed<<" KM/H "<<endl;
        }
    int LamboHorsePower()
        {
            lHorsePower=1000;
            cout<<" Lamborghini produces "<<lHorsePower<<" HP"<<endl;
        }
    private:
        float lAcceleration;
        string lBrake;
        int lTopSpeed;
        int lHorsePower;
    
};
int main(int argc, char *argv[])
{
    //objects for vehicle class
    cout<<" _________________objects for vehicle________________________"<<endl;
    Vehicle car;
    car.Steer();
    car.Accelerate();
    //cout<<car.vRight;
    cout<<" _________________objects for porsche________________________"<<endl;
    cout<<endl;
    Porsche Cayenne;
    cout<<Cayenne.pName;
    Cayenne.PorscheTopSpeed();
    Cayenne.PorscheHorsePower();
   // Cayenne.Steer(car);
    cout<<endl;
    cout<<endl;
    
    cout<<" _________________objects for lamborgini________________________"<<endl;
    cout<<endl;
    Lamborghini Murcielago;
    Murcielago.LamboHorsePower();
    Murcielago.Steer(); // using steer function found only in vehicle class
    cout<<endl;
    //car.vBrake = "Braking"; //use this as private
    //cout << "Press the enter key to continue ...";
    //cin.get();
    system("pause");
    return EXIT_SUCCESS;
}
</code>

Polygon count

19 November 2012 - 08:17 AM

Hi people,
I would like to know how i can get a polygon count for my 3D scene.
It will be purely for statistics so something simple will suffice.
My program is an l-system tree generator and i want to know
how many polygons are used to draw the various trees.
Any help is greatly appreciated.

Save openGL objects to file

12 October 2012 - 04:19 AM

Hi guys,
I am making an L-sytem tree application. I require a way to save the generated models into a text file(.obj seems the best as it saves the vertices). Check this site for the L-system framework
I know how read and write to a text with plain C++ but the withOpenGL it is not straight forward.
Can someone please provide me with any help on this matter.?
Preferablly an example like saving the openGL cube or teapot veryices into a text file. Thanks

[opengl] Drawing curves and arcs

14 August 2012 - 01:31 AM

Hi guys,
I am trying to draw arcs and curves in opengl. I am trying to modify this tutorial on swiftless
so far i have tried using GL_POINTS and GL_LINE_STRIP but to no avail. Your help is greatly
appreciated.Thanks

PARTNERS