C++ - Class doesn't work ... program won't compile.

losslessgggs 101 Apr 28, 2012 at 05:32

First of all, I deeply, deeply, deeply hate object-oriented programming, but since every fucking thing requires it, I guess there’s no choice, and I’m basically about to quit programming altogether because I’m getting very sick of it.

This code won’t compile:

#include <iostream>
using namespace std;
class CR
    int cope;
int main()
    CR::cope = 20;
    return 0;

error: invalid use of non-static data member ‘CR::cope’

2 Replies

Please log in or register to post a reply.

asvsfs 101 Apr 28, 2012 at 06:02

you cant access to non static member variable like that you should first make an instance from your class then use its members …

CR * myClass = new CR();
myClass->cope = 20;
CR myClass;

you should read before you start coding ,… and if you hate oop programming and hate reading you should quit at all

alphadog 101 May 01, 2012 at 20:32

If you hate OOP because it’s too hard, try Haskell or LISP. If that’s still too hard, try Malbodge.