2 Compiler Errors

I am trying to write a class interface and an imp\lementation to get this program to print out the surface area and volume of a soda can I ran in to the following two errors and can not figure out how to fix them:

line 25: Error E2333 lab5a.cpp 25: Class member 'SodaCan::SodaCan(int,int)' declared outside its class
line 26: Error E2040 lab5a.cpp 26: Declaration terminated incorrectly

#include <iostream>

using namespace std;

/**
   A cylindrical can.
*/

//define interface here:
#define pi = 3.14159
class SodaCan
{
      public:
             
            SodaCan(int height, int radius);
            
            double get_volume();
            double get_surface_area();
            
      private:
            double volume;
         double surface_area;
};
      
SodaCan::SodaCan(int height, int radius);
      {
            volume = pi*radius*radius*height;
            surface_area = 2*pi*radius*height + 2*pi*radius*radius;
      }
      
double SodaCan::get_volume()
      {
        return volume;
      }

double SodaCan::get_surface_area()
      {
        return surface_area;
      }

// a driver:
int main()
{
   SodaCan can(10, 5); //height is 10, and radius is 5
   cout << can.get_volume() << "\n";
   cout << can.get_surface_area() << "\n";
   return 0;
}

       
 
Geezy1984Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sunnycoderCommented:
Hi Geezy1984,

> SodaCan::SodaCan(int height, int radius); <<<<< remove the terminating ;
>      {
>           volume = pi*radius*radius*height;
>           surface_area = 2*pi*radius*height + 2*pi*radius*radius;
>      }


Cheers!
Sunnycoder
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rajeev_devinCommented:
>> SodaCan::SodaCan(int height, int radius);
Remove semi-clon from it

SodaCan::SodaCan(int height, int radius)
     {
          volume = pi*radius*radius*height;
          surface_area = 2*pi*radius*height + 2*pi*radius*radius;
     }
0
Raj_KauCommented:
#include <iostream>

using namespace std;

/**
   A cylindrical can.
*/

//define interface here:
#define pi = 3.14159
class SodaCan
{
     public:
           
          void SodaCan(int height, int radius);
         
          double get_volume();
          double get_surface_area();
         
     private:
          double volume;
        double surface_area;
};
     
void SodaCan::SodaCan(int height, int radius);
     {
          volume = pi*radius*radius*height;
          surface_area = 2*pi*radius*height + 2*pi*radius*radius;
     }
     
double SodaCan::get_volume()
     {
       return volume;
     }

double SodaCan::get_surface_area()
     {
       return surface_area;
     }

// a driver:
int main()
{
   SodaCan can(10, 5); //height is 10, and radius is 5
   cout << can.get_volume() << "\n";
   cout << can.get_surface_area() << "\n";
   return 0;
}
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Raj_KauCommented:
SodaCan::SodaCan(int height, int radius);
remove this ";" from end
0
Raj_KauCommented:
sorry full code is like this





#include <iostream>

using namespace std;

/**
   A cylindrical can.
*/

//define interface here:
#define pi = 3.14159
class SodaCan
{
     public:
           
          void SodaCan(int height, int radius);
         
          double get_volume();
          double get_surface_area();
         
     private:
          double volume;
        double surface_area;
};
     
void SodaCan::SodaCan(int height, int radius)
     {
          volume = pi*radius*radius*height;
          surface_area = 2*pi*radius*height + 2*pi*radius*radius;
     }
     
double SodaCan::get_volume()
     {
       return volume;
     }

double SodaCan::get_surface_area()
     {
       return surface_area;
     }

// a driver:
int main()
{
   SodaCan can(10, 5); //height is 10, and radius is 5
   cout << can.get_volume() << "\n";
   cout << can.get_surface_area() << "\n";
   return 0;
}
0
sunnycoderCommented:
Hi Geezy1984,
> #define pi = 3.14159
should be
#define pi  3.14159

#defines make literal substitution


Cheers!
Sunnycoder
0
HuyBDCommented:
try to move ; in implement , you have declared correddconstructor before

SodaCan::SodaCan(int height, int radius)
{
do somt;
}


try to check syntax before compile!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.