Jump to content

Simple C++ Program With Classes

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
LukeyJ

LukeyJ

    Learning Programmer

  • Members
  • PipPipPip
  • 93 posts
I am completely losing my marbles here, I've digested a fair few concepts and a reasonable amount of information on classes. When I have a go at an example, it is not working. I've downloaded 3 different IDE's because it's frustrating me that much and I thought it was a Visual Studio problem.

It's clearly me that is the problem. Could someone point out what I'm doing wrong. I have some really abstract ideas I'd like to try but I can't get past the basics. Thanks.

The code:
#include <cstdlib>

#include <iostream>


//using namespace std;

using std::cout;

using std::endl;


class Test_Class

{

      Public:

             int var1;

             int var2;

             

};

             



int main(int argc, char *argv[])

{

    Test_Class example;

    

    system("PAUSE");

    return EXIT_SUCCESS;

}

The errors:
Compiler: Default compiler

Building Makefile: "C:\Dev-Cpp\Projects\Makefile.win"

Executing  make...

make.exe -f "C:\Dev-Cpp\Projects\Makefile.win" all

g++.exe -c main1.cpp -o main1.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"   


main1.cpp:11: error: expected primary-expression before "int"

main1.cpp:11: error: ISO C++ forbids declaration of `Public' with no type

main1.cpp:11: error: expected `;' before "int"


make.exe: *** [main1.o] Error 1


Execution terminated


#2
LukeyJ

LukeyJ

    Learning Programmer

  • Members
  • PipPipPip
  • 93 posts
Haha, I'm so retarded. public: is case sensitive!

Aaaaaaaaarrrgggggggghhhhhhhhhhhhhhh. I'm going to throw myself off the nearest building.

#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
gotta love case-sensitivity in C++. I think it's one of the reasons my boss prefers Delphi.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
LukeyJ

LukeyJ

    Learning Programmer

  • Members
  • PipPipPip
  • 93 posts
Love is certainly not a word I'd use... the amount of programs I've made just to try and find where I was going wrong. I thought it was something about the type of program I was trying to make. Whether it be windows or console. Bah!