|
If I have
public class AImplementation:IAInterface { void IAInterface.AInterfaceMethod() { } void AnotherMethod() { ((IAInterface)this).AInterfaceMethod(); } }
How to call AInterfaceMethod() from AnotherMethod() without explicit casting?
Started by Jader Dias on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Public class....
You can't
Can't you just remove the "IAInterface." from the method signature?
public class AImplementation : IAInterface { public void AInterfaceMethod() { } void AnotherMethod() { this.AInterfaceMethod(); } }
Tried this and it works.. .
|
|
Possible Duplicate:
What does the explicit keyword in C++ mean?
What is explicit constructor in C++ and what is its purpose?
Started by rayimag on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
But if you make the constructor explicit, this kind of implicit conversion can't happen:
class....
FruitBasket fb = 5; // Legal.
)); // OK std::auto_ptr<int> r(0x58588); // Error
Explicit constructors force your constructors); } // ...
|
|
Actually my question is all in the title.
Anyway:
I have a class and I use explicit constructor:
.h
class MyClass { public: explicit MyClass(const string& s): query(s) {} private: string query; }
Is it obligatory or not to put explicit keyword in implementation...
Started by chester89 on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
My gcc says:
test.cpp:6: error: only declarations of constructors can be 'explicit'
for the following code:
class foo { public: explicit foo(int); }; explicit....
The explicit keyword is only permitted in the header.
No, it is not.
|
Ask your Facebook Friends
|
Output:
B->Hello! from Explicit.
Shouldn't it be:?
A->Hello! from Explicit.
Why doesn't explicit cast (IHello)a call IHello.Hello() from class A? interface IHello { void Hello(); } class A : IHello { public virtual void Hello() { Console.WriteLine...
Started by Naximus on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
The output is exactly as expected.
Is located:
If S contains a declaration of an explicit interface member implementation that matches to Hello() will call object B's explicit implementation of Hello.
|
|
What are the differences in implementing interfaces implicitly and explicitly in C#?
When should you use implicit and when should you use explicit?
Are there any pros and/or cons to one or the other?
Started by Seb Nilsson on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
Myclass.CopyTo //invalid with explicit ((....
Explicit implentation allows it to only be accessible when cast as the interface itself.
Explicit is when you define.
Implicit is when you define your interface via a member on your class .
|
|
That is the question. Is there anything you can do with c++ unions that you can't with c# Explicit structs?
Started by devoured elysium on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
C# explicit structs have some problems when it comes to references)" is not a compile-time constant (unlike C++ sizeof), it is impossible to use pointer-sized members in explicit, it is possible to use ....
The layout in C# with structs.
|
|
How to implement explicit interface implementation in VB.NET?
Started by mcxiand on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Explicit interface implementation in C# also allows.
Just one more word.
Through the interfaces.
|
|
Hi, Plese tell me Difference between explicit and implicit type cast.
Started by Vijjendra on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
An IList<int> )
With an explicit cast, either you are telling the compiler that you know more; float f = i;
With an explicit primitive conversion, it is likely that the conversion could lose; // explicit (extracts text from....
|
|
What are the instances where you need to explicitly call a destructor?
Started by jasonline on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
F->~foo(); ::operator delete....
When you use placement-new is a common reason (the only reason?):
struct foo {}; void* memoryLocation = ::operator new(sizeof(foo)); foo* f = new (memoryLocation) foo(); // note: not safe, doesn't handle exceptions // .. .
|
|
I have a dll that contains a templated class. Is there a way to export it without explicit specification?
Started by Boyan on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
This is the only way to give users to freedom to use any type with the template... .
That is, the library that is using the dll can instantiate the template .
Since the code for templates is usually in headers, you don't need to export the functions at all .
|