-2

I am reading about classes in Python and encountered the following statement:

In C++ terminology, normally class members (including the data members) are public (except see below Private Variables), and all member functions are virtual.

I have never heard this, is it true? I tried doing some research, but I only found articles explaining when to make a function virtual and what virtual means.

  • Read this: https://stackoverflow.com/questions/2391679/why-do-we-need-virtual-functions-in-c – Stefan Falk Oct 12 '17 at 06:41
  • I think the quote has itself confused, it is not true, certainly not true that data members are public in a class! – arynaq Oct 12 '17 at 06:42
  • This is a statement about Python, not about C++. It is of course false when applied to C++. – n. m. could be an AI Oct 12 '17 at 06:42
  • @n.m. well, he says "in C++ terminology"? –  Oct 12 '17 at 06:43
  • Doesn't it mean "if you want to do the same thing in C++ as Python, you need to make all the member function public and virtual." ? – songyuanyao Oct 12 '17 at 06:44
  • 1
    Yes, it is a statement about Python expressed in C++ terminology. Your Python course doesn't attempt to teach you C++. It teaches you Python. It explains how Python behaves, using vocabulary you might know from C++. – n. m. could be an AI Oct 12 '17 at 06:51

1 Answers1

2

This is a statement about python. It is saying to a person who knows C++, that python classes have public members and virtual functions.

So the statement is true, but slightly out of context.

mksteve
  • 12,614
  • 3
  • 28
  • 50