Questions tagged [explicit]

In C++ specifies constructors and conversion operators that don't allow implicit conversions or copy-initialization. In C# declares a user-defined type conversion operator that must be invoked with a cast. For MS SQL Server for-xml-EXPLICIT mode use the [for-xml-explicit] tag

405 questions
7
votes
1 answer

Does implementing Interface both implicit and explicit make sense?

I'm currently studying for my MS 70-515 exam. In one of the practices the author implements an interface both implicit as well as explicit. The explicit implementation just calls the implicit implementation. The explicit implementation is just…
comecme
  • 6,086
  • 10
  • 39
  • 67
6
votes
2 answers

How can I import dll of a C++ class inside a namespace

I read some documents which gives simple examples on functions compatible with C. __declspec(dllexport) MyFunction(); I'm okey with that. I write a small application uses the functions of this dll. I used explicit linking with LoadLibrary()…
qwerty
  • 2,065
  • 2
  • 28
  • 39
6
votes
4 answers

Explicit keyword applied to operator instead of constructor

In the class below, Why would you make the operators explicit. I thought that explicit was to prevent implicit calling of constructors? class Content { public: virtual ~Content() = 0; virtual explicit operator float&(); virtual…
cherry aldi
  • 327
  • 1
  • 10
6
votes
1 answer

What is better implicit conversion through constructor or explicit function in this case?

I am creating my own class for String using C++ solely for learning purposes. And I stuck upon the place where I should make a decision. Let me explain the matter. I have two options of my class. I will post below only relevant pieces of the code…
6
votes
3 answers

How come I can't use explicit constructor for constructing a return type

I played around with explicit constructors and their behavior, so I created this class: #include class X { public: explicit X(void) { std::cout << "Default constructor\n"; } explicit X(X const& x) { …
hgiesel
  • 5,430
  • 2
  • 29
  • 56
6
votes
2 answers

ASP.NET: explicit vs implicit localization?

To my mind the advantage of implicit localization over explicit localization is that if you have more than one property to localize for a given control, it's a more economical syntax. In the case where you just need to localize some text I use the…
User
  • 62,498
  • 72
  • 186
  • 247
6
votes
1 answer

When to use explicit specifier for multi-argument constructors?

I have recently learned about the explicit specifier. Suppose we have: f( W, W, W ); Now if we do f( 42, 3.14, "seven" ); The compiler will attempt the following implicit conversions: f( W(42), W(3.14), W("seven") ); If we have defined matching…
P i
  • 29,020
  • 36
  • 159
  • 267
6
votes
2 answers

When must we use implicit and explicit operators in C#?

What is the usage of these operators?
masoud ramezani
  • 22,228
  • 29
  • 98
  • 151
6
votes
2 answers

Entity framework Explicit Loading multi-level

I tried load multi-level with explicit loading but an error occurred: "The property path 'Channel.Posts' cannot be used for navigation properties. Property paths can only be used to access primitive or complex properties." This is my code: var…
6
votes
2 answers

Is it possible to infer template parameters of tuple from brace-type initialization?

In this example, is it possible to allow the deduction of the template parameters type of the tuple? #include #include template void fun(std::tuple t, std::string other){} int main(){ …
alfC
  • 14,261
  • 4
  • 67
  • 118
6
votes
2 answers
6
votes
2 answers

Why does position of explicit template instantiation matter

Say I declare a template class A in a.h #include template class A { public: void print(std::ostream& out); }; And define the print method in a.cpp (with explicit instatiation for true and false) #include "a.h" template
Dejan Jovanović
  • 2,085
  • 1
  • 16
  • 22
5
votes
2 answers

Freakishly weird interface polymorphism using interface composition

I ended up with something like the following code in a project I'm working on. I thought it was really odd that I was allowed to do it, but now I'm starting wonder what is most likely an architectural gaff on my part led me to this. My questions to…
Scott Muc
  • 2,873
  • 27
  • 38
5
votes
2 answers

Explicit instantiation of function template specialization

I am trying to create a global function template specialized for some given types. It looks something like that: A.h (primary template, template specialization, extern) template void foo() { std::cout << "default stuff" << std::endl;…
Touloudou
  • 2,079
  • 1
  • 17
  • 28
5
votes
2 answers

C# Generics - Calling generic method from a generic class

I have the following classes and I am trying to call Compare method from ExportFileBaseBL class but I get the error Cannot implicitly convert type 'Class1' to 'T'. An explicit conversion exists (are you missing a cast?) public abstract class…
logik6
  • 127
  • 1
  • 5