Suppose I've this:

class A
{
    public:
    virtual int hello(A a);
};

class B : public A
{
   public:
   int hello(B b){ bla bla };
};

So, A this is an abstract class.

1)Within the class B, I am determining a technique that it is suppose overrides the A category. However the parameter it's slightly different. I am unsure relating to this, is correct? Maybe due to polymorphism, this really is ok nevertheless its rather confusing. 2) Basically do: A a = new B, after which a.hello(lol) if "lol" it isn't of type B, it gives compile error?, and when it's of type A from another class C (class C : public A), an amount happend?

I am unclear about the overriding and virtual factor.. all good examples I discovered use techniques without parameters.

Any answer, link, or whatever it's appreciated.

thanks

pd: sorry for my british

Your class B does not override the member function inside a, it overloads it. Or attempts to anyway, begin to see the bit about hiding later.

Overriding happens when a derived class defines its very own version of the virtual member function from the base class. Over-loading happens when you define different functions with similar title.

Whenever a virtual call is created on the pointer or reference which has the kind of the bottom class, it'll only "consider" overrides within the derived class, not overloads. This really is essential - for a clear case of B to become treated by phone callers as if it will everything a b can perform (the reason for dynamic polymorphism and virtual functions), its hello function must have the ability to take any object of type A. A hello function which only takes objects of type B, instead of any A, is much more limited. It cannot act as A's hello function, therefore it is no override.

Should you experiment a little with calling hello on the and B, passing objects of type A or B, you need to have the ability to begin to see the difference. A includes a function taking a b (that you simply haven't defined, if you refer to it as your program will neglect to link, however, you can deal with that). B includes a function going for a B. They have exactly the same title, not to mention since B derives from the, you are able to pass a b - towards the function taking a b. But B's function does not behave as an override in virtual calls.

You'll be able to call A's function on the B object, only using a reference or pointer to some. An element of C++ would be that the meaning of hello in B hides the meaning inside a. If over-loading is what you would like, you can not-hide the bottom class function with the addition of using A::hello; to class B. If overriding is what you would like, you need to define a function using the same parameters. For instance:

#include <iostream>

class A
{
    public:
    virtual int hello(A a) {std::cout << "A\n"; }
    virtual int foo(int i) { std::cout << "A::Foo " << i << "\n"; }
};

class B : public A
{
   public:
   using A::hello;
   // here's an overload
   int hello(B b){ std::cout << "B\n"; };
   // here's an override:
   virtual int foo(int i) { std::cout << "B::Foo " << i << "\n"; }
};

int main() {
    A a;
    B b;
    a.hello(a);  // calls the function exactly as defined in A
    a.hello(b);  // B "is an" A, so this is allowed and slices the parameter
    b.hello(a);  // OK, but only because of `using`
    b.hello(b);  // calls the function exactly as defined in B
    A &ab = b;   // a reference to a B object, but as an A
    ab.hello(a); // calls the function in A
    ab.hello(b); // *also* calls the function in A, proving B has not overridden it
    a.foo(1);    // calls the function in A
    b.foo(2);    // calls the function in B
    ab.foo(3);   // calls the function in B, because it is overridden
}

Output:

A
A
A
B
A
A
A::Foo 1
B::Foo 2
B::Foo 3

For away the using A::hello; line from B, then your call b.hello(a); does not compile:

error: no matching function for call to `B::hello(A&)'
note: candidates are: int B::hello(B)