|
You are welcome!
But I can not be more specific because I don't know what you wanna do from what you described. I never said "adding a new method" in my previous posts to create the "ambiuous call" condition.
|
|
|
|
|
Ok, to be more specific, I have redefined the otherclass to enable it has an << operator:
class otherclass
{
public:
otherclass(void):i(0) {}
friend std::ostream & operator << (std::ostream & os, otherclass &Obj)
{
os << Obj.i;
return (os);
}
int i;
};
In the Serialize_SFINAE name space, I modified it to handle the otherclass serialization:
namespace Serialize_SFINAE
{
template <typename T>
auto Serialize(T& obj, std::ostream &os) -> decltype(obj.Serialize(os),void())
{
obj.Serialize(os);
}
template <typename T>
void Serialize( T& obj, std::ostream &os, ...)
{
os << obj;
}
}
So now the program can handle the otherclassserialization. However, when switch back to myclass, compiler generate an ambiguous call message: error C2668: 'Serialize_SFINAE::Serialize' : ambiguous call to overloaded function
So what should the second Serialize(..) within that name space be in order to handle the object without Serialize internally implemented?
|
|
|
|
|
Well, you actually changed the signature of the Serialize method. You are not allowed to do that. If you want to be able to access a stream for this purpose then put both of these methods into a class instead, store a stream reference/pointer in the class, create an instance of that class and call these sfinae methods of the instance. This way you don't have to change the signature of the sfinae methods. A simpler less nice alternative is not changing the methods but accessing the stream from a global variable.
|
|
|
|
|
Good. That's clarify what I thought and is what I planed to do after the last post.
Thanks again for your kind explanations.
|
|
|
|
|
|
|
|
Good afternoon.
Quote: how can i improve my c programming in different ways?
Coding. Reading good books. Coding. Coding. (did I say 'coding'?).
Veni, vidi, vici.
|
|
|
|
|
Someone on these forums told me that there is a difference in quality between a coder and a programmer. I wish OP to become a programmer, a software engineer. Programming. Programming. Software engineering. Software engineering. Design. Design.
I see the point of OP, he is probably searching for motivators but the first thing to write as a beginner programmer is not a monumental masterpiece and usually not even useful application. Becoming able to write something monumental and/or useful (like a compiler, an operating system kernel, a serious game) requires years of experience - the way is quite long and many "wannabe" programmers don't realize that this can be achieved only by enjoying the way. Many starters give up and some of them reach only the level of a bad programmer usually without satisfactory software design knowledge.
|
|
|
|
|
Back in the early years of my programming career I started with asm programming. I still remember how happy I was when I first put together a "for loop" in an assembly program (at home, I wasn't forced by teachers). It was something that read in some input from the keyboard and then printed it the the screen when the enter key was pressed or something similarly stupid stuff. In assembly even this simple program was a challenge for me despite the fact that it was only a stupid for loop (I didn't even knew that it was a for loop, I only knew that I require a few jumps and condition checking). You have to search for a challange that keeps you motivated but isn't too far beyond what you can achieve with your current knowledge. If that knowledge is zero then the first step is reading books and the code of others'. Don't try to skip reading 1-2 books on C programming, you will regret it and you will waste a lot of time by progressing with much slower speed by doing nothing because of being able to do nothing without the necessary basic knowledge. I can easily imagine that you think your biggest problem is the C programming language itself but you should quickly realize that the language itself is only a tool and the real value is the experience you gain by solving problems. Every language of the same paradigm contains the same basic constructs (loops, functions, classes, ...). The sooner you get through the learning of your first language (for example C) the sooner you can start with solving real-world problems and gaining experience in software design that is much more important than being able to produce compilable lines of code in a language. Without experience even the smallest problems seem to be unsolvable, it requires 1-2 years spent with valuable programming to learn the basic patterns (for example how to read in data and parse it, how to manage memory, ...) in order to be able to handle these naturally without effort by concentrating your efforts on solving the real problems built on top of the simple patterns.
|
|
|
|
|
Uh oh, its the pastapizza daily novel!
Hey, did you ever hear what paragraphs are? Try using them occasionally.
--edit--
I see a sense of humour is lacking in some.
modified 21-Aug-13 10:57am.
|
|
|
|
|
(but scaring at first sight )
Veni, vidi, vici.
|
|
|
|
|
I'm good at writing scaring paragraphs. I have always been terrible in literature, grammar and similar things...
|
|
|
|
|
No no no no no!
It doesnt go 'Good Evening' it goes 'Hello World!'
Dear oh dear, how are you ever going to learn if you dont get this right!
|
|
|
|
|
Veni, vidi, vici.
|
|
|
|
|
Member 9857487 wrote:
how can i improve my c programming in different ways
Learn how compilers and linkers work. That knowledge will increase your understanding of how the C language works.
|
|
|
|
|
Hello. I'm trying to open exe file , but there is a problem like this:
<<assert failure="" in="" qlist::operator[="" ]:="" "index="" out="" of="" range",="" file="" c:\qt\4.8.1\include\qtcore\..="" ..="" src="" corelib="" tools="" qlist.h,="" line="" 477="">>
but I can compile without debuging or I can debug it, and there is no problem; it works correctly:
what is it a problem at time opening exe file?
thanks for attention
|
|
|
|
|
Please do not create multiple accounts in order to post the same question twice.
Use the best guess
|
|
|
|
|
Possibly the worst sock puppetry act ever.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
How dense can you be? Its the value you are passing to the Qlist::[] opperator! Its telling you that it is too big!
Holy crap, I wish I had error messages this easy.
If you dont understand that accessing member 2909483625284948 of a 22 member array is a bad thing then go get another job.
|
|
|
|
|
f*** you Erudite_Eric
Do you think that you are smart, but you're awfully stupid
|
|
|
|
|
Actually I know I am stupid, thats why I force myself to think very carefully about things.
|
|
|
|
|
Sometimes it's better to say nothing .
|
|
|
|
|
Especialy without thinking first.....
|
|
|
|
|
Hello. I'm trying to open exe file , but there is a problem like this:
<<assert failure="" in="" qlist::operator[="" ]:="" "index="" out="" of="" range",="" file="" c:\qt\4.8.1\include\qtcore\..="" ..="" src="" corelib="" tools="" qlist.h,="" line="" 477="">>
but I can compile without debuging or I can debug it, and there is no problem; it works correctly:
what is it a problem at time opening exe file?
thanks for attention
|
|
|
|