Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am taking a C++ class in my school. Since I've programmed in Ruby I know some OOP stuff.

But in C++ there are member functions, member variables, and static functions. In Ruby we have instance methods, instance variables, and class variables. And there are more...

Any reason they're different? Are they quite different levels of OOP? Or just some differences in tradition these ecosystems have?

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

Instance in Ruby and member in C++ are effectively the same thing, so instance variables and member variables are the same, as are instance methods and member functions.

However, static members are somewhat different from class variables in Ruby since the the Ruby object model is quite different to C++. In Ruby, classes are objects, so class variables are instance variables of a class object.

share|improve this answer
add comment

They are just different names for the same thing. You see the same thing with inheritance: base vs. parent vs. super classes. School teachers and people who only know one language will sometimes be very pedantic about the terms. In industry you'll find people mixing and matching more often.

share|improve this answer
add comment

The concepts - or as you call them, levels - of OOP are similar or the same across OO languages and a lot of the differences in terminology come out of the history and tradition of the languages and their ecosystems. That's why you're seeing different terms used to describe very similar concepts when you're comparing the two languages.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.