Thread: Why cannot I compile these with Dev-C++?

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    26

    Why cannot I compile these with Dev-C++?

    Hello,

    I've two examples, directly taken by my C++ manual, with no changes made by me.

    You can find the main program file and the header file attached.

    When I try to compile the project I have these errors:

    Code:
      [Linker error] undefined reference to `Stock::Stock(char const*, int, double)'
      [Linker error] undefined reference to `Stock::Stock(char const*, int, double)' 
      [Linker error] undefined reference to `Stock::Stock(char const*, int, double)' 
      [Linker error] undefined reference to `Stock::Stock(char const*, int, double)' 
      [Linker error] undefined reference to `Stock::~Stock()' 
      [Linker error] undefined reference to `Stock::show() const' 
      [Linker error] undefined reference to `Stock::topval(Stock const&) const' 
      [Linker error] undefined reference to `Stock::show() const' 
      [Linker error] undefined reference to `Stock::~Stock()' 
      [Linker error] undefined reference to `Stock::~Stock()' 
      [Linker error] undefined reference to `Stock::~Stock()' 
      [Linker error] undefined reference to `Stock::~Stock()' 
      ld returned 1 exit status
    Can you please help me?
    Thank you!

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    You have to also include stock2.cpp in your project. Do you have that file?

  3. #3
    Registered User
    Join Date
    Feb 2008
    Posts
    26
    Now got it and included. It works.

    THANK YOU

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compile problem on linux
    By cnb in forum C Programming
    Replies: 3
    Last Post: 09-29-2008, 04:14 AM
  2. auto_ptr assignment compile error
    By George2 in forum C++ Programming
    Replies: 7
    Last Post: 04-01-2008, 02:44 AM
  3. Compile as you type
    By Rocketmagnet in forum A Brief History of Cprogramming.com
    Replies: 33
    Last Post: 12-07-2006, 01:36 PM
  4. Dev C++ Won't Compile
    By mburt in forum Windows Programming
    Replies: 8
    Last Post: 08-21-2006, 11:14 PM
  5. Compile crashes certain windows
    By Loduwijk in forum C++ Programming
    Replies: 5
    Last Post: 03-26-2006, 09:05 PM

Tags for this Thread