Thread: Need help on pure virtual method

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    6

    Need help on pure virtual method

    Hi Guys

    I need to implement an abstract base class shape containing following pure vitual methods

    - void draw() const;
    -ostream &print(ostream &o) const;

    can anybody help me with it

    I tried following is it correct?

    [class Shape
    {
    public:
    Shape()
    {
    }

    virtual ~Shape()
    {
    }

    virtual void draw() const = 0;
    ostream & print(ostream &o) const = 0;
    };

    ]
    Thanks

    Wanex
    Last edited by wanex; 03-23-2006 at 07:01 PM.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    post the code you're having trouble with.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Looks fine to me.

    Code tags look like this:
    [code]
    Your code here.
    [/code]

  4. #4
    Registered User
    Join Date
    Mar 2006
    Posts
    6
    thanks man

  5. #5
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Quote Originally Posted by Daved
    Looks fine to me.
    Quote Originally Posted by wanex
    thanks man
    That might possibly be the easiest help you've ever given, Daved.
    Sent from my iPadŽ

  6. #6
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    I remember this homework assignment. It was that famous tutor/paid cheat that posted the requirements.

  7. #7
    Registered User
    Join Date
    Mar 2006
    Posts
    6
    Well I am a student, do you remember as well if there was any solutions for that assigment?

  8. #8
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Quote Originally Posted by wanex
    Well I am a student, do you remember as well if there was any solutions for that assigment?
    As a person that was given this assignment when I was in this class... I can tell you that, yes... there is a solution.
    Sent from my iPadŽ

  9. #9
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    Well I am a student, do you remember as well if there was any solutions for that assigment?
    Well, it sounds if as you are a cheater too. Here's an idea: how about you actually do the programming yourself?

  10. #10
    Registered User
    Join Date
    Mar 2006
    Posts
    6
    Quote Originally Posted by 7stud
    Well, it sounds if as you are a cheater too. Here's an idea: how about you actually do the programming yourself?
    I already done and submited it, I was just curious if there was any alternative/better solutions for it. whats your problem anyway?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 10-28-2009, 09:25 AM
  2. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  3. Pure Virtual Function - Virtual Method Table
    By u_peerless in forum C++ Programming
    Replies: 8
    Last Post: 06-07-2008, 01:19 AM
  4. Information Regarding Pure Virtual Functions
    By shiv_tech_quest in forum C++ Programming
    Replies: 6
    Last Post: 01-29-2003, 04:43 AM
  5. C++ XML Class
    By edwardtisdale in forum C++ Programming
    Replies: 0
    Last Post: 12-10-2001, 11:14 PM