C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 31st, 2013, 02:54 PM
rb2633 rb2633 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 1 rb2633 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 21 sec
Reputation Power: 0
Classes - Link Errors when working with Classes and IMPs (Beginner)

I'm am my second semester of Computer Science II C++. I got a 98 in the first semester and everything seemed really easy, but this semester seems a bit harder. Also, this is my first forum post. Any help would be appreciated!
I'm learning about working with classes, header files and IMP files associated. We're supposed to have two classes: 'circleType' and 'cylinderType', with their implementation files and a source file. Finding total costs and shipping etc (shown down below in code).
I've got mostly all of the meat in the program. It compiles in VS2012 but has two errors:

1:Source.obj : error LNK2019: unresolved external symbol "public: __thiscall cylinderType::cylinderType(double)" (??0cylinderType@@QAE@N@Z) referenced in function _main

2:C:\Users\rawda_000\documents\visual studio 2012\Projects\Discussion Unit 1\Debug\Discussion Unit 1.exe : fatal error LNK1120: 1 unresolved externals

Any help to fix this linking error would be greatly appreciated! My files are down below.
Again, thanks!

********** "circleType.h" **********
#ifndef H_CircleType
#define H_CircleType

class circleType
{
public:
void setRadius(double radius);
double getRadius();
double getArea();
double getCircumference();

void print() const;

circleType(double radius = 0);

protected:
double radius;
};

#endif
****************************************

******** circleTypeImp.cpp **********
#include <iostream>
#include <iomanip>
#include "circleType.h"

using namespace std;

void circleType::setRadius(double radius)
{
if (radius >= 0)
radius = radius;
else
radius = 0;
}

double circleType::getRadius()
{
return radius;
}

double circleType::getArea()
{
return 3.1416 * radius * radius;
}

double circleType::getCircumference()
{
return 2 * 3.1416 * radius;
}
circleType::circleType(double radius)
{
radius = radius;
}
*******************************************

********** cylinderType.h **********
#ifndef H_CylinderType
#define H_CylinderType

#include "circleType.h"

class cylinderType: public circleType
{
public:
double getHeight() const;
double getSurfArea() const;
double getVolume() const;

void print() const;

cylinderType(double height = 0);

private:
double surfArea, volume, height;
};

#endif
******************************************

********** cylinderTypeImp.cpp **********
#include <iostream>
#include <iomanip>
#include "cylinderType.h"
#include "circleType.h"

using namespace std;

double radius = 0;
double height = 0;

double cylinderType::getSurfArea() const
{
return ((2 * 3.1416 * radius * radius * height) + (2 * 3.1416 * radius * height));
};
double cylinderType::getVolume() const
{
return (3.1416 * radius * radius * height);
};
cylinderType::cylinderType (double height) const
{
height = height;
};
*******************************************

********** source.cpp **********
#include <iostream>
#include <iomanip>
#include "circleType.h"
#include "cylinderType.h"

using namespace std;

int main ()
{
circleType circle;
cylinderType container;
double shipping, shippingCost, paintCost,estPaintCost, total;
double radius = 0, height = 0;

cout << "Enter the dimensions (in feet) of the container "
"(radius of the base then the height, separated by a space)." << endl;
cin >> radius >> height;
cout << endl;

cout << "Enter the shipping cost per liter." << endl;
cin >> shipping;
cout << endl;

cout << "Enter the paint cost per square foot." << endl;
cin >> paintCost;
cout << endl;

estPaintCost = paintCost * container.getSurfArea();
shippingCost = container.getVolume() * shipping;

cout << "Your shipping cost is: $" << shippingCost << "." << endl;
cout << endl;

total = estPaintCost + shippingCost;
cout << "Your total cost of painting is: $" << total << "." << endl;

system("PAUSE");
return 0;
}
***************************************

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Classes - Link Errors when working with Classes and IMPs (Beginner)


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap