I have been trying to differentiate c and c++(or oop languages) but I don't understand where the difference is.
Note I have never used c++ but I asked my friends and some of them to differentiate c and c++
They say c++ has oop concepts and also the public, private modes for definition of variables and which c does not have though. Seriously I have done vb.net programming for a while 2 to 3 months, I never faced a situation to use class concepts and modes of definition like public and private. So I thought what could be the use for these?
My friend explained me a program saying that if a variable is public, it can be accessed anywhere I said why not declare it as a global variable like in c? He did not get back to my question and he said if a variable is private it cannot be accessed by some other functions I said why not define it as a local variable, even these he was unable to answer.
No matter where I read private variables cannot be accessed whereas public variables can be then why not make public as global and private as local whats the difference? whats the real use of public and private ? please don't say it can be used by everyone, I suppose why not we use some conditions and make the calls?
I have heard people saying security reasons, a friend said if a function need to be accessed it should be inherited first.
He explained saying that only admin should be able to have some rights and not all so that functions are made private and inherited only by the admin to use
Then I said why not we use if condition
if ( login == "admin")
invoke the function
he still did not answer these question. Please clear me with these things, I have done vb.net and vba and little c++ without using oop concepts because I never found their real use while I was writing the code, I'm a little afraid am I too back in oop concepts?
© Programmers or respective owner