|
Good suggestion!
|
|
|
|
|
Write a set of free functions that take const string references and spit out strings modified the way you want. There are a couple of observations here...
First one is that just because a function isn't a member of a class doesn't mean that it violates some great principle of OO. A free function can be as much a part of a class's interface even if it's not a member:
class A
{
public:
A &operator+=( const A &add_to );
};
A operator+( const A &a, const A &b )
{
A temp( a );
temp += b;
return temp;
} In this example the freestanding operator+ is very much part of A's interface. As is the usual practice of declaring an insertion and/or extraction operator to do input or output:
class B
{
public:
friend std::ostream &operator<<( std::ostream &str, const B &print_me );
friend std::istream &operator>>( std::ostream &str, const B &load_me );
}; Second one is that C++ isn't just an OO language. OO is probably the dominant idiom but even hardcore OO programmers use a fair number of generic techniques e.g:
std::string to_upper( const std::string &source )
{
std::string upper_case( source.size(), 0 );
std::transform( begin( source ), end( source), begin( upper_case ), toupper );
return upper_case;
} and:
std::string &to_upper_in_place( std::string &upper_case_me )
{
std::string temp = to_upper( upper_case_me );
std::swap( temp, upper_case_me );
return upper_case_me;
} They're both free functions but the second works very much like you'd defined a member of std::string.
Anyway, I've gone on enough. The points I was trying to make are:
- free functions can be part of a class's interface
- if a class hasn't been built to be extended by inheritance (which std::string isn't) then you have to use free functions to extend it
modified 31-May-12 12:40pm.
|
|
|
|
|
|
This is better than some of the articles we see on here. How about posting this into Tips & Tricks for the benefit of the community as a whole?
|
|
|
|
|
I'll have a crack at that over the weekend, thanks for the suggestion.
|
|
|
|
|
Hello Experts,
I want to know how to create a Remote desktop Application in Visual C++ 6.0 (i.e in MFC),I have good knowledge in MFC,but I need to create my own program.
Is there any chance I can create it using C++
Please let me know.
Regards
Kiran
|
|
|
|
|
Please explain what you mean by "Remote desktop Application"?
|
|
|
|
|
Member 9052985 wrote: Is there any chance
Doesn't seem like there's much.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
If you have "good knowledge in MFC", then you should already know what you can do in C++.
In order to create a remote desktop app, you need to know a few things:
0.Sockets (maybe secure sockets while you're at it).
1.Server-client applications.
2.Screen capture methods.
3.Mouse/keyboard capture methods (and the inverse, how to transmit the captured keys).
Can you do it in C++, literally, no... you have to use APIs that are OS dependent... but that's just a technicality, so yes.. you can do it in C++ (with proper use of APIs).
|
|
|
|
|
|
I am trying to animate my object like below, the object should move back and forth, but with this i can't see the movement. please tell me whats going wrong in this code below. Thanks Sujan
[code]
CDC* pDC = GetDC();
wglMakeCurrent(pDC->m_hDC, m_hrc);
transObj2[0]=transObj2[0] - 40.0f;
Invalidate();
Sleep(5000);
transObj2[0]=transObj2[0] + 40.0f;
Invalidate();
Sleep(5000);
wglMakeCurrent(NULL,NULL);
[/code]
|
|
|
|
|
But there's no drawing code!
OpenGL maintains the positions of your vertices and polygons for 1 frame.
In this sample you never tell GL anything, except the HDC of the window you'd like it to draw in. Even this looks a little suspicious. Generally, one would get the HDC of a static control and throw that to GL.
You've not draw the objects at all, hence you'll not see them drawn in different positions.
Go lookup Nehe OpenGL tutorials. Or even 'Rotate Triangle openGL'...
|
|
|
|
|
MY OBJECT IS THERE I DINT POST THE DRAWSCENE PART OF THE CODE. IT'S DRAWN ON THE SCREEN, ONLY DIFFICULTY I AM FACING IN SIMULATING IT. I WANT THE OBJECT TO MOVE BACK AND FORTH FOR 1 MINUTE. HOW CAN I ACHIEVE THIS PLS HELP.
|
|
|
|
|
YOUR REWARD FOR YELLING IS NOTHING!
That's right, I'm going to give you nothing.
Bugger off!
|
|
|
|
|
You might like to remove the obscenity from the above.
|
|
|
|
|
Not a word or construct used in the above post is not used in (free to air) tv commercials, played at any hour of the day in this country. To which are you referring?
(I assume it is the aussie version of sod off)
|
|
|
|
|
|
I really can't be bothered with this rubbish.
Am I to take it from you that the following are insults?
- Go away
- Nick off
- Sod off
- Bugger off
I'd agree that some may consider it insulting to be told to go away - I consider it insulting to be forced to vote in a democracy.
But neither being told to go away or being required to vote is an insult. You may want to turn down the gain on your sensitivity stage.....
|
|
|
|
|
enhzflep wrote: You may want to turn down the gain on your sensitivity stage.....
I am not in the least bothered by such expressions. I just agree with Chris that this sort of language is not appropriate in the general forums.
|
|
|
|
|
I won't bother pointing out the fact that you've changed your complaint when challenged.
I will point out that - I provided information that indicated the problem I had with the offending post
- There was no insult in my reply
- There was no sarcasm in my post
- There was no slap-down handed out
- Each of the words used are entirely 10 y/old sister safe
I've resigned myself to the realization that if you're prepared to agree, the best we can do is to agree to disagree.
If that still doesn't suit you, I suggest you follow point 4 of "HOW TO ANSWER A QUESTION" with regards to my post that you deem so awful. Should there be sufficient repetitions of that direction, my post will evaporate. Before that point, I will not be taking a step backwards.
|
|
|
|
|
enhzflep wrote: I won't bother pointing out the fact that you've changed your complaint when challenged.
I've changed nothing; you are merely trying to justify your use of offensive language.
|
|
|
|
|
Indeed. On reflection, I did make a muck of that. I'd erroneously recalled that you first declared it an insult.
Clearly, your definition of offensive and mine do not match. However, it is kid-sister safe.
So, do we agree to disagree?
|
|
|
|
|
enhzflep wrote: So, do we agree to disagree?[Coffee]
Sure, although I'm drinking tea at the moment.
|
|
|
|
|
Makes two of us. (drinking tea at the moment, that is)
|
|
|
|
|
And just for the record, nothing in the foregoing exchange changes my opinion of your technical abilities (which is on the high side).
|
|
|
|