Debugging help

This is a discussion on Debugging help within the C++ Programming forums, part of the General Programming Boards category; Could someone please tell me why when I run this the output is only: 1 1 1 1 1 press ...

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    7

    Debugging help

    Could someone please tell me why when I run this the output is only:

    1
    1
    1
    1
    1
    press any key to continue

    I am using VC++ 6.0 and have run the debugger but this is all it says:

    Loaded 'C:\WINNT\system32\ntdll.dll', no matching symbolic information found.
    Loaded 'C:\winnt\system32\kernel32.dll', no matching symbolic information found.
    The thread 0x1CC has exited with code 0 (0x0).
    The program 'C:\Microsoft Visual Studio\MyProjects\Addressbook\Debug\Addressbook.ex e' has exited with code 0 (0x0).

    Any help is appreciated.

    Code:
    //Address.h
    #ifndef ADDRESS_H
    #define ADDRESS_H
    #include <string>
    #include <iostream>
    
    class address{
            
            std::string street;
            std::string city;
            std::string state;
            std::string zipcode;
            
     public:                                
    		address::address (const std::string s=" ",
                      const std::string c=" ",
                      const std::string st=" ",
                      const std::string z=" ");
                                                                                          
    	 address::address (const address &a);
    		  void setstreet   (const std::string s);
    		  void setcity     (const std::string c);
    		  void setstate    (const std::string st);
    		  void setzipcode  (const std::string z);
    		    std::string getstreet    (void) const;
    		    std::string getcity      (void) const;
    		    std::string getstate     (void) const;
    		    std::string getzipcode   (void) const;
    		    
                std::string tostring (void) const;
    };
    #endif // ADDRESS_H
    
    //Address.cpp
    
    #include "address.h"
    #include <sstream>
    
     address::address (const std::string s,
                           const std::string c, 
                           const std::string st, 
                           const std::string z){
                          street=  s;
                          city=    c;
                          state=   st;
                          zipcode= z;
                      }
                     
     address::address (const address &a){
            street= a.getstreet();
            city=   a.getcity();
            state=  a.getstate();
            zipcode=a.getzipcode();
        }   
        
           
            std::string address::getstreet(void) const {
                return street;
            };
            
            std::string address::getcity(void) const {
                return city;
            };
            
            std::string address::getstate(void) const {
                return state;
            };
            
            std::string address::getzipcode(void) const {
                return zipcode;
            };
            
            void address::setstreet (const std::string s){
                street=s;
            };             
            
            void address::setcity (const std::string c) {
                city=c;
            };
            
            void address::setstate (const std::string st) {
                state=st;
            };       
            
            void address::setzipcode (const std::string z) {
                zipcode=z;
            };   
            
            std::string address::tostring(void) const{
                std::ostringstream ss;
                ss<<street<<'\n'<<city<<", "<<state<<" "<<zipcode;
                return ss.str();
            };        
            
    //Testaddress.cpp
    
    #include "address.h"
    #include <iostream>
    int main (void){
            address A1;
                  std::cout<<A1.tostring<<std::endl;
            
            address A2 ("123 Main");
                   std::cout<<A2.tostring<<std::endl;
                  
            address A3 ("55 Oak" , "somewhere" , "Nevada" , "12345");
                    std::cout<<A3.tostring<<std::endl;
            
            address A4(A3);
                    std::cout<< A4.tostring<<std::endl;
    
            A4.setstate ("CA");
                    std::cout<<A4.tostring<<std::endl;
    return 0;
    }

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    public:
    address::address (const std::string s=" ",

    drop the address:: from the above
    ___________________________________
    int main(void)

    drop the void and just use int main()
    ___________________________________
    std::cout<<A1.tostring <<

    there should be () after tostring each time, as it is a function call
    __________________________________

    #include "address.h"
    #include <iostream>

    I always put all the < > includes before any " " includes, though I don't know if that is mandatory or not
    ___________________________________
    see if that fixes the errors.

  3. #3
    Registered User
    Join Date
    Oct 2004
    Posts
    7

    thank you so much

    Thank you so much, that worked, and well lets just say I am very relieved.

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    You're welcome. Learning how to read the error statements and warnings takes time, just like writing code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dev-C++: Problems with Breakpoint Debugging
    By Thileepan_Bala in forum C Programming
    Replies: 1
    Last Post: 01-17-2008, 09:48 AM
  2. Problem in debugging in Eclipse
    By Bargi in forum Linux Programming
    Replies: 1
    Last Post: 08-21-2007, 09:53 AM
  3. Debugging Dev C++
    By tuurb046 in forum Tech Board
    Replies: 10
    Last Post: 08-16-2007, 12:51 PM
  4. Debugging book recommendation
    By dagans in forum Projects and Job Recruitment
    Replies: 1
    Last Post: 09-13-2005, 07:35 PM
  5. debugging directx apps
    By confuted in forum C++ Programming
    Replies: 1
    Last Post: 08-16-2003, 08:56 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21