#include<iostream>
class base
{
int m_data;
public:
base(const int data):m_data(data){}
base(const base& cpy):m_data(cpy.m_data){}
base& operator=(const int rhs){m_data=rhs;return(*this);}
base& operator=(const base& rhs){m_data=rhs.m_data;return(*this);}
virtual ~base(){}
};
class derived
{
public:
derived(const int data):base(data){}
derived(const derived& cpy):base(cpy){}
derived& operator=(const int rhs){return(base::operator=(rhs));}
derived& operator=(const derived& rhs){return(base::operator=(rhs));}
virtual ~derived(){}
};
int main()
{
derived d=42;
}
what is the pure algorithm instead of cpp program?
Such a program is called a Quine. http://en.wikipedia.org/wiki/Quine_(computing)
Use the scope resolution operator (::) to explicitly call the base class method. Note that the base class method must be protected or public in order for a derived class to access it. Private members are only accessible to the class itself and to friends of the class, regardless of whether the derivative uses public, protected or private inheritance. It is quite normal for a base class to provide a "default" implementation for a virtual method for which a derived class may override. Although the derived class will generally provide its own implementation of the method, it may also call the base class method either before, during or after performing its own implementation. The following shows minimal class declarations demonstrating a call to a protected base class method from a derived class override. class base { protected: // accessible to all instances of this class, its friends and its derivatives. virtual void method(){ /* do something */ } }; class derived : public base { public: // full-accessible outside of class. virtual void method(){ /* do something (or do nothing) */ base::method(); // call base class method. /* do something else (or do nothing) */ } };
The .cpp extension is merely conventional; it is not required by the C++ standard. You can actually use any file extension you wish.
int main (void) { puts ("charminar"); return 0; }
what is the pure algorithm instead of cpp program?
Yes because a program can run without a CPP extension, especially if program extension is .exe
An object is an instance of a class.
Go to the link. You will got use of "this" keywork with simple explanation and example. http://cpp.codenewbie.com/articles/cpp/1527/Keyword_this-Page_5.html
Such a program is called a Quine. http://en.wikipedia.org/wiki/Quine_(computing)
Use the scope resolution operator (::) to explicitly call the base class method. Note that the base class method must be protected or public in order for a derived class to access it. Private members are only accessible to the class itself and to friends of the class, regardless of whether the derivative uses public, protected or private inheritance. It is quite normal for a base class to provide a "default" implementation for a virtual method for which a derived class may override. Although the derived class will generally provide its own implementation of the method, it may also call the base class method either before, during or after performing its own implementation. The following shows minimal class declarations demonstrating a call to a protected base class method from a derived class override. class base { protected: // accessible to all instances of this class, its friends and its derivatives. virtual void method(){ /* do something */ } }; class derived : public base { public: // full-accessible outside of class. virtual void method(){ /* do something (or do nothing) */ base::method(); // call base class method. /* do something else (or do nothing) */ } };
class superclass { public: superclass() {... } // c'tor public: virtual ~superclass() {... } // d'tor }; // superclass class derived: public superclass { public: derived() : superclass() { ... } // derived c'tor public: virtual ~derived() {... } // derived d'tor }; // derived class
The .cpp extension is merely conventional; it is not required by the C++ standard. You can actually use any file extension you wish.
The extension of a file containing a C program can be any extension, so long as the compiler or platform can infer the proper rules to build it. Commonly, for C programs, the extension is .c, so myfile.c would be a C program. The term cpp is not a designation for C++. It means C Program Precompiler, and it is the normal way to build one or more C programs into an executable. Over the years, cpp has evolved into being able to handle all sorts of languages. C++ is one of them. Typical extensions for C++ programs are .cc, .cpp, and .cxx.
int main (void) { puts ("charminar"); return 0; }
The logic to create such programs is very simple. We know that rules of programming languages. Among them the most important one is "We should not use keywords as identifiers". Based on this rule we can create many programs that execute in c but not in cpp. Suppose write a program to and two numbers. Store the two values in two variables, name the variables as class and object. then execute in c. it will produce the output, and do the same thing in cpp, it will give two errors. because we used keywords as identifiers in cpp. ex:-#include<stdio.h> #include<conio.h> void main() { int class=10,object=26,res; res=class+object; printf("%d",res); getch(); } Or: char str3[3] = "ABC"; /* doesn't compile in C */
That is possible. Try it.