Thread: Need help get this working

  1. #16
    Registered User
    Join Date
    Feb 2011
    Posts
    1

    C++ Help!

    Hello every one, This is my 1st post. I have the same assignment as the Thread starter, I figured I would post my question here.
    I'm using VB 2010 express to compile and I choose the C++ version.


    I know Im missing some things including code in my .cpp definitions of functions, but that's half of where Im confused and I had to run out to take a test, maybe when I get back in 4 hours someone will have some things to add. Thanks in advance. I Could also be reached @ Twitter

    Here is my CODE:l

    Code:
    #ifndef PersonType_H
    #define PersonType_H
    
    
    
    
    class PersonType
    {
    public:
    	PersonType();//Defualt Constructor
        PersonType(string, string);//Constructor with parameters
        
        void setName(string first, string last);//Function to set firstName and lastName
    	void getName(string& first, string last);//Function to return firstName and lastName through the parameters	    
    	void print() const;    //Function to output the first name and last name
    private:
       string firstName; //DataMember first name    
       string lastName;  //DataMember last name
    
    
    };
    #endif
    
    #include "stdafx.h"
    #include <iostream>
    #include <cstring>
    
    
    using std::cout;
    using std::endl;
    using namespace std;
    
    #include "PersonType.h"
    
    PersonType::PersonType(string first, string last)//Default constructor;
    	{
      	    firstName = fist; //store the first name    
    		lastName = last;  //store the last name
    	}
    
    void personType::setName(string first, string last)
    	{
    		firstName = first;
    		lastName = last;
    	}
    void PersonType::getName()
    	{
    
    	}
    
    void PersonType::print()const 
        {
    		cout<<firstName<<" "<<lastName;
    	}
    
    #include "stdafx.h"
    using namespace System;
    #include <cstdlib>
    #include <iostream>
    
    
    #include "PersonType.h"
    
    int main()
    {
       PersonType pName(David, Barco);
       const pName.setName;
       const pName.getName;
       const pName.printName;
       
       
       
        system("PAUSE");
        return EXIT_SUCCESS;
    }


    ERRORS:

    C++ WA 4 B2.cpp(8): warning C4603: 'PersonType_H' : macro is not defined or definition is different after precompiled header use
    Add macro to precompiled header instead of defining here
    C++ WA 4 B2.cpp(30) : use of precompiled header
    C++ WA 4 B2.cpp(39): fatal error C1083: Cannot open include file: 'PersonType.h': No such file or directory

  2. #17
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Rebuild your project, see if it helps. And next time, it is better that you start your own thread and point to an existing thread if the thread discusses the same problem as you have.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function not working
    By sloopy in forum C Programming
    Replies: 31
    Last Post: 11-12-2005, 08:08 PM
  2. Program Not working Right
    By raven420smoke in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2005, 03:21 AM
  3. Trying to eject D drive using code, but not working... :(
    By snowfrog in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2005, 07:47 PM
  4. x on upper right corner not working
    By caduardo21 in forum Windows Programming
    Replies: 1
    Last Post: 02-20-2005, 08:35 PM
  5. cygwin -> unix , my code not working properly ;(
    By CyC|OpS in forum C Programming
    Replies: 4
    Last Post: 05-18-2002, 04:08 AM