Tamas Marki wrote:
> On 3/24/07, Robert Ryan <[EMAIL PROTECTED]> wrote:
>> I want to make a square, a circle and a triangle in C++
>> do I start off with just making generalizations about a Shape and then
>> get specific for each shape
>
> And your question is...?
>
>> #include <iostream>
>> using namespace std;
>> class Shape {
>> double Diam = 0;
>
> You cannot assign a default value to a member like this. You have to
> use a constructor.
Actually, I'm pretty sure I saw that the up-and-coming Standard changes
are going to allow that syntax so you don't need to write a constructor.
But, at the moment, it isn't allowed.
OP: Squares and triangles don't have a diameter. Just circles. Safe
C++ Design Principles - Chapter 10, subsection Base Classes. Read it.
The book is free for c-prog members in the Files section of the c-prog
website.
>> double Circum1 = 0;
>> double Circum2 = 0;
>> double Circum3 = 0;
>> }
>
> Class definitions need to end with a semicolon.
>
>> public Square extends Shape {
>
> This is not the C++ syntax of inheritance (maybe it's Java?).
> Proper way:
>
> Square : public Shape {
class Square : public Shape
{
> Those are just some syntax errors, I'm not going to make comments on
> the correctness of your logic.
> Please at least post syntactically correct snippets of code, along
> with your questions.
> The least you could do is to let your program through a compiler to
> spot the obvious errors.
There's that need for an Internet compile & run utility again. In this
case, just the compile part.
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* VerifyMyPC 2.3
Change tracking and management tool.
Reduce tech. support times from 2 hours to 5 minutes.
Free for personal use, $10 otherwise.
http://www.CubicleSoft.com/VerifyMyPC/