Classes Help

This is a discussion on Classes Help within the C++ Programming forums, part of the General Programming Boards category; Header File: Code: #ifndef __Assign5__h #define __Assign5__h #include <iostream.h> #include <iomanip.h> class cSTRING { public: //Members Variables char* cStr; int ...

  1. #1
    eat my shorts!
    Join Date
    Apr 2002
    Posts
    294

    Classes Help

    Header File:
    Code:
    #ifndef __Assign5__h
    #define __Assign5__h
    #include <iostream.h>
    #include <iomanip.h>
    
    class cSTRING
    {
    public:
    
    	//Members Variables
    	char* cStr;
    	int nLen;
    
    	//Constructors
    	cSTRING(char cStr = '\0', int nLen=0);
    	cSTRING(char* cStr);
    
    	//Destructor
    	~cSTRING();
    
    	//Prototypes
    	int SetStringLength(char*);
    	char* SetStringCopy(char*,char*);
    
    	//Inspectors
    	const int GetStringLength( cSTRING& str );
    	const char* GetString();
    
    	//Methods
    	void Display (cSTRING& str);
    }
    #endif
    CPP FILE:
    Code:
    #include <iostream.h>
    #include "Assign5.h"
    
    void main (void)
    {
    	cSTRING str;
    	int nStrLen;
    
    	char str[50];
    	cout << "Enter a String: ";
    	cin >> str;
    }
    i am getting these errors:
    error C2143: syntax error : missing ';' before 'PCH creation point'
    error C2040: 'str' : 'class cSTRING' differs in levels of indirection from 'char [50]'
    Games Reviews Previews Desktop Themes Downloads Paintball Forums Shareware Freeware and much more

    The best in Technology and Gaming News

    www.back2games.com

  2. #2
    Disturbed Boy gustavosserra's Avatar
    Join Date
    Apr 2003
    Posts
    244
    You should put a ';' after the definition of the class:
    Code:
    class X{
    
    };
    Nothing more to tell about me...
    Happy day =)

  3. #3
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Just quickly glancing over your code:
    Code:
    class someclasss
    {
    
    };<---
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >#ifndef __Assign5__h
    >#define __Assign5__h
    One underscore == bad. Two underscore == really really really really really really really really really really really really really really really really really really really okay I think that's enough. Just don't use two leading underscores, kay? For that matter, don't use a leading underscore and an uppercase letter either.

    >#include <iostream.h>
    >#include <iomanip.h>
    Drop the .h, these are no longer correct C++ headers.

    >void main (void)
    int main(), no exceptions. Well, except for the handful of exceptions, but they're pretty exceptional, so just pretend there are no exceptions.

    >char str[50];
    You already declared a variable called str.
    My best code is written with the delete key.

  5. #5
    ...
    ... is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    >Well, except for the handful of exceptions, but they're pretty exceptional, so just pretend there are no exceptions.


    what are the exceptions?
    I came up with a cool phrase to put down here, but i forgot it...

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    Basically, if you aren't returning control to anything, it's considered acceptable (kernels, imbedded OS's, etc).
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

  7. #7
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >what are the exceptions?
    When main takes arguments:
    Code:
    int main ( int argc, char **argv )
    When the compiler supports extensions:
    Code:
    int main ( int argc, char **argv, char **envp )
    On a freestanding implementation all restrictions are off. You can pretty much do what you want because the standard doesn't impose any limitations on you. That's the only case where void main would be valid.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you Initialize all classes once with New?
    By peacerosetx in forum C++ Programming
    Replies: 12
    Last Post: 07-02-2008, 10:47 AM
  2. Multiple Inheritance - Size of Classes?
    By Zeusbwr in forum C++ Programming
    Replies: 10
    Last Post: 11-26-2004, 08:04 AM
  3. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  4. Exporting VC++ classes for use with VB
    By Helix in forum Windows Programming
    Replies: 2
    Last Post: 12-29-2003, 04:38 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM

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