how to define -std=c++11 as default in g++

Yes, you typically set this in a Makefile: One layer above you can also detect a suitable compiler via autoconf, cmake or whichever other meta-buildtool you might deploy. You of course play games as define g++11 as g++ -std=c++11 but such set-ups are not portable. g++-6.* will default to c++14 so at some this switch will be implicit. But it might take … Read more

AttributeError: ” object has no attribute ”

Your NewsFeed class instance n doesn’t have a Canvas attribute. If you want to pass the Canvas defined in your Achtergrond class instance hoofdscherm to n, you can define it under the class definition for NewsFeed using __init__(): Then when you initialize your NewsFeed object as n, you can pass the Canvas instance from your Achtergrond class instance hoofdscherm: This is a solution to your current issue, but there are other errors in your code that you can see … Read more

Separating class code into a header and cpp file

The class declaration goes into the header file. It is important that you add the #ifndef  include guards. Most compilers now also support #pragma once. Also I have omitted the private, by default C++ class members are private. and the implementation goes in the CPP file:

Java: Multiple class declarations in one file

My suggested name for this technique (including multiple top-level classes in a single source file) would be “mess”. Seriously, I don’t think it’s a good idea – I’d use a nested type in this situation instead. Then it’s still easy to predict which source file it’s in. I don’t believe there’s an official term for … Read more

Does Python have “private” variables in classes?

It’s cultural. In Python, you don’t write to other classes’ instance or class variables. In Java, nothing prevents you from doing the same if you really want to – after all, you can always edit the source of the class itself to achieve the same effect. Python drops that pretence of security and encourages programmers to be … Read more

(->) arrow operator and (.) dot operator , class pointer

you should read about difference between pointers and reference that might help you understand your problem. In short, the difference is:when you declare myclass *p it’s a pointer and you can access it’s members with ->, because p points to memory location. But as soon as you call p=new myclass[10]; p starts to point to array and when you call p[n] you get a reference, which members … Read more

C++ Linked List Node with class

Specifically, the goal here is to create a linked structure that has some number of nodes, between 5 and 2 million. Don’t worry that this number is large or that values may wrap around past the max size of integer. If you have created your linked structure correctly, a modern computer can breeze through this … Read more

Single class has a Class Redefinition Error

You need header guards on that header file. It is presumably being included twice. Modify the header, adding these lines to the beginning and end. The define doesn’t need to be STUDENT_H… it just needs to be unique. With these directives added, the compiler will ignore all contents of the header file if it has already been parsed. … Read more