Click here to Skip to main content

Comments by Emilio Garavaglia (Top 200 by date)

Emilio Garavaglia at 16-Aug-13 4:04am View
   
Reason for my vote of 3 \n It's all a matter of taste. Good justifications for yours, but anyone else may have good ones for his own.
Emilio Garavaglia at 16-Mar-13 17:14pm View
   
gee, at least post a link: this is a website, after all!
Emilio Garavaglia at 14-Feb-13 5:52am View
   
This is a non-sense: if you are restricted to only C++ you can use std::string being std::string part of the C++ spec, otherwinse you are not using C++ (in proper sense).
 
Unless the real problem is the use of dynamic memory, but in that case the way you prototyped wont help, since
- you still need it and ...
- you will be in trouble managing it:
 
In general, returning a char* is not a good C++ practice, sine it is not clear who got the memory it points to and who will be in charge to release it. Your functions -as they are now- are potential sources of memory leaks.
 
Much better can be writing yourself a class that wraps that pointer and keep managing the memory itself.
 
But OOPS... that will be nothing more than another std::string or CString or whatever.
So what's the clue, here?
Emilio Garavaglia at 6-Feb-13 11:01am View
   
Good in OOP school sense, "Type case defeats the purpose of OOP, abuses it" can become harmful if abused conversely: there is a risk to place in the base class all the potential methods of all it's potential derived. This is called a "god-object". The "good thing" stays somewhere in the middle. But no "school" models it.
Emilio Garavaglia at 5-Feb-13 7:24am View
   
I've no doubt it works, but that's not C++, since it refers to functions belonging to the C standard library and not to the C++ one. It works because of backward compatibility, but if everything "works with both C and C++" there is no clue to have C++ at all.
Emilio Garavaglia at 5-Feb-13 2:38am View
   
This is C, not C++
Emilio Garavaglia at 2-Sep-12 15:54pm View
   
r-values ARE object and are constructed, copied and destroyed like every other object. (think to x and y as std::string, instead of integers: x+y is a std::string itself, constructed on the return of operator+, and made available to the next operation in the chain.
 
The fact you cannot take the address is due to its "temporary nature", that makes that address dangling as soon the expression gets evaluated. You cannot get the address because their is anything "persistent" that survives between consecutives sequence points.
Emilio Garavaglia at 20-Jul-12 7:03am View
   
Yes, but that "move" will move individual characters from the old (small) buffer to the new (large) one, and hence it will not be different from a copy, since you cannot re-use the old buffer.
 
The advantage happens if the vector is a vector<unique_ptr<something>>: in that case the ptr-s are "moved" from one buffer to the other, in fact disabling the destruction of the pointed objects from the destroying buffer by the ptr-s destructors.
 
Emilio Garavaglia at 20-Jul-12 2:59am View
   
Copy vs Move is not involved here: += doesn't copy, it just makes the size counter increment, and the added character copied (it must be, since it has to go into the string buffer from outside: a character, like any built-in type as any "register-wide type" that is "moved" is in fact "copied": you can "move" only things that are accessed indirectly).
 
If the size goes over the capacity, an new wider buffer is allocated, the content copyed (move and copy characters is exactly the same) and the old buffer dismissed.
 
You can "move" a buffer from a string to another, but moving buffers in this context make no sense, since to enlarge it you have to change it (hence you need another one).
Emilio Garavaglia at 17-Jul-12 4:23am View
   
Its not "C that work like htis". It is the compiler(s) you use.
The language dosen't "work", It tells "how a compiler should work". void main is not part of the C specification. The fact compilers accept it is not by itself changing the specification of the language.
 
It works because the combination of compiler/linker/platform you work on admits it, not because the language requires it.
 
There is a difference between "admit" and "require": by providing samples of "working code" you demonstrate what is admitted. By providing official specification (you din't) you demonstrate hat is required (and I'm talking about).
 
They are different things. You cannot use one to demonstrate the other.
Emilio Garavaglia at 17-Jul-12 2:29am View
   
... "And in Microsoft documentation is no reference to void main".
It no "holy war": it's history. void main() was introduced by microsoft C in 1988. Subsequent standardization of both C (from 1990) and C++ (1996/99/03/11) never formalized that variant.
 
Today MS adhere to the standard and don't mention the fact that void main exist and compiles mainly to retain backward compatibility.
 
As per the standard, a C function with no return type specifyed is int not void.
 
void main is an extension, not a standard part of the language. And being an extension, compiler writers are not required to implement it.
 
If you are convinced about this is just a war, please cite me the page and line of the ISO specification of the C and C++ languages of 2011 that state void main is part of the standard.
 
I can agree with you this is probably not the most important thing in programming, but the C language is what the ISO cometee says it is. Your and my opinoins about it are irrelevant in that context.
Emilio Garavaglia at 17-Jul-12 2:28am View
   
Deleted
... "And in Microsoft documentation is no reference to void main".
It no "holy war": it's history. void main() was introduced by microsoft C in 1988. Subsequent standardization of both C (from 1990) and C++ (1996/99/03/11) never formalized that variant.
 
Today MS adhere to the standard and don't mention the fact that void main exist and compiles mainly to retain backward compatibility.
 
As per the standard, a C function with no return type specifyed is int not void.
 
void main is an extension, not a standard part of the language. And being an extension, compiler writers are not required to implement it.
 
If you are convinced about this is just a war, please cite me the page and line of the ISO specification of the C and C++ languages of 2011 that state void main is part of the standard.
 
I can agree with you this is probably not the most important thing in programming, but the C language is what the ISO cometee says it is. Your and my opinoins about it are irrelevant in that context.
Emilio Garavaglia at 16-Jul-12 14:45pm View
   
The point is not if it "works" or not. i that is it "standard" or not. And not: it is not standard since the language specification don't specify any void main().
 
Actually it is just a microsoft extension other implementors support, but that is not granted to be supported everywhere because no one is formally required to implement that capability.
 
Emilio Garavaglia at 4-Jun-12 9:33am View
   
^ in mathematical formulas is commonly called (and read as) "hat" (italian: "cappello") at least in Italy. I never heard as "hook" for integral as well. I suspect it's not a matter of technical culture, but of its localization.
 
BTW: # is usually called "gate" and @ "snail"
Emilio Garavaglia at 4-Jun-12 9:33am View
   
Deleted
^ in mathematical formulas is commonly called (and read as) "hat" (italian: "cappello") at least in Italy. I never heard as "hook" for integral as well. I suspect it's not a matter of technical culture, but of its localization.
Emilio Garavaglia at 26-May-12 9:18am View
   
You must tell us WHAT you have tried, otherwise we cannot help you.
There is no reason we can hep someone entering a company without the required knowledge: your future colleague cannot solve all the problems you are in charge of.
Emilio Garavaglia at 2-May-12 3:55am View
   
The proper prototype for copy constructor is Human(const Human&), otherwise certain expression and standard library functions may not work.
Emilio Garavaglia at 21-Apr-12 10:43am View
   
Don't post fake answers that are in fact questions. Improve the original question instead (or post another, in unrelated)
Emilio Garavaglia at 21-Apr-12 10:42am View
   
The question is tagged C++. void* are not to be introduced in C++ programs not related to C modules.
Emilio Garavaglia at 10-Apr-12 14:50pm View
   
VAT = Value Added Taxes.
If you ask to "professionals" to do something entirely for you, they need to be payed.
Emilio Garavaglia at 10-Apr-12 14:48pm View
   
VAT = Value Added Taxes.
 
If you ask to "professionals" to do something entirely for you... they need to be payed.
Emilio Garavaglia at 10-Apr-12 13:19pm View
   
Ohhhh ... fantastic!
 
But if you can read and write hidden file, every programmer can. How long do you think will last until an utility for that purpose will came around?
The explorer is nothing more tham the evolution of the file manager that is the evoultion of the ... Norton Commander!
Emilio Garavaglia at 28-Mar-12 8:18am View
   
Invoice = The way we have to be payed from you
Emilio Garavaglia at 14-Mar-12 5:55am View
   
No, for that same reason: the hardware is managed by the OS, that hosts the applications (ALL of them).
 
Imagine two apps wishing to do different things to a same device or port...
 
What you can do is ask the system to give the full control of a port to you, hiding away to every other app, until you give it back (but now you have an USB serial: forget about file systems, you have to write your own), or writing something IN the system (a driver) that manipulates the data-flow towards a given port or device.
 
Note that some devices have this capability themselves (have a switch that can be positioned in a "deny write" mode). If you have that need, you probably should go towards that kind of devices.
Emilio Garavaglia at 13-Mar-12 17:40pm View
   
Thanks.
Fixed some more by me ...
 

Emilio Garavaglia at 13-Mar-12 16:54pm View
   
WTF is Celsius to Fahrenheit conversion related to the title ????
Emilio Garavaglia at 13-Mar-12 15:39pm View
   
hey ... this pseudocode looks like ... COBOL! :-)
Emilio Garavaglia at 13-Mar-12 9:20am View
   
Deleted
" would u give me the source document of what is called a class declaration, pls?"
I can do even more: the last available draft fo the C++ STANDRARD is
here: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf.
 
C++ is nothing less and nothing more than that.
Of course you can criticize thet specifications and think a different way around,
but cosider also that you're not alone on earth: there are more than 20 year of history of C++
(and more man 30 year of history of C) that still have to be compiled if included in whatever
new code that is actually using them.
 
C# history is much and much shorter, and there is no such a backlog to be compatible with.
C# is "another way of think OOP over C" in respect of what the C++ way is.
(in case you're interested, you can also look at Java (http://docs.oracle.com/javase/specs/) or
D (http://dlang.org) and you will see two other ways.
C++ is object oriented as C# is. The difference is in what the claim an "object" to be.
They don't reason the same, and manipulate different things they both call "object".
They cannot be compared each other.
 
When a language designer defines how a language should be he also have to take care about
how much pre-existent code it whats to continue to use.
C++ designers choose to reatain all the C libraries (they compile in C++ as well),
define a language that implements the OOP, Generic and functional paradigms
and still retain compativbility with 30y.o. code.
C# designer where much more relaxed about that: tehy interface C, but don't compile it inside.
 
Your cosideration can be interesting, but ask yourself for each of them: "how much
preexisting code will break if a further compiler start behaving as I'm thinking of?"
if you retain just the last 10 years, and follow the OOP way specificately, than C# is for you
(but how much C# is out there when you go out from Windows?)
If you have to retain 30+ years, c# cannot be for you: it changes too frequently.
Emilio Garavaglia at 13-Mar-12 9:12am View
   
" would u give me the source document of what is called a class declaration, pls?"
I can do even more: the last available draft fo the C++ STANDRARD is
here: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf.
 
C++ is nothing less and nothing more than that.
Of course you can criticize thet specifications and think a different way around,
but cosider also that you're not alone on earth: there are more than 20 year of history of C++
(and more man 30 year of history of C) that still have to be compiled if included in whatever
new code that is actually using them.
 
C# history is much and much shorter, and there is no such a backlog to be compatible with.
C# is "another way of think OOP over C" in respect of what the C++ way is.
(in case you're interested, you can also look at Java (http://docs.oracle.com/javase/specs/) or
D (http://dlang.org) and you will see two other ways.
C++ is object oriented as C# is. The difference is in what the claim an "object" to be.
They don't reason the same, and manipulate different things they both call "object".
They cannot be compared each other.
 
When a language designer defines how a language should be he also have to take care about
how much pre-existent code it whats to continue to use.
C++ designers choose to reatain all the C libraries (they compile in C++ as well),
define a language that implements the OOP, Generic and functional paradigms
and still retain compativbility with 30y.o. code.
C# designer where much more relaxed about that: tehy interface C, but don't compile it inside.
 
Your cosideration can be interesting, but ask yourself for each of them: "how much
preexisting code will break if a further compiler start behaving as I'm thinking of?"
if you retain just the last 10 years, and follow the OOP way specificately, than C# is for you
(but how much C# is out there when you go out from Windows?)
If you have to retain 30+ years, c# cannot be for you: it changes too frequently.
Emilio Garavaglia at 13-Mar-12 4:06am View
   
And you should answer to the correct post ...
Actually you posted to me, that I'm not the OP, and I'm not asking a question.
;-)
Emilio Garavaglia at 13-Mar-12 3:58am View
   
The reliable source about C++ specification is the specification itself, not MSDN.
 
As per the spcs:
 
class FORWARD DECLARATION is
class A;
(just a symbol)
 
class DECLARATION is
class A { ... };
(just a bunch of symbols and a way to compute space)
 
method DECLARATION is
rettype name(params ...);
(again just symbols)
 
method DEFINITION is
rettype name(params ...) { ... }
(imply machine code to be produced)
 
varaible DEFINITION is
type name = type(params ...); (or other syntactic shortcuts)
(imply the reservation of memory space)
 
There is no concept of "class definition" since a non instantiated class is ... nothing.
 
You can mix method definitions into class declarations, like
class A { void method() {} };
because that definition, being into a class decl, is implicitly considered as inline and hence CAN BE REPEATED, like inline function are (and stay in header files).
 
But C++ designed din't define an equivalent "inline variable definition" hence static variables definitions - like all variables or non integral constants - cannot be repeated, hence canto stay into a declaration.
 
About your comparison of C# and C++, you can have all the personal opinion you like, but what you did is a technical nonsense: if C++ must be like C# it will be c# itself and if C# must be like C++ will be C++ itself.
 
C++ and C# are different languages that target different programming domains.
C++ is closer to the metal than C# actually is: "everyting derived from object" is considered bad practice from modern C++ programmers, since will lead to unnecessary overhead for certain kind of situation a SYSTEM programmer have to deal with and a USER programmer (I mean a programmer writing useer-targetted programs) don't have to.
 
The correct answer is choose the appropriate language for the problem you have to solve and respect the design guides that language carries on. Don't try to make one to work as the other: it just mean you are using the wrong one. Just use the other.
 
The main difference between C# and C++ is that in C# objects are "referenced", while in C++ objects are "values". And references have to be explicitly managed.
 
What I proposed is not a "workaround to make things to work". Is what C++ requires an object to be designed. That's a completely different story than what C# requires.
Emilio Garavaglia at 12-Mar-12 18:17pm View
   
Answer updated.
Emilio Garavaglia at 5-Mar-12 14:34pm View
   
"I think you would agree..." Of course.
 
Unless you need to give citizenship to the concept of "not existent".
In that case, a pointer is useful.
And where reference where required ... I saw sometimes the *(A*)0 trick!
Emilio Garavaglia at 5-Mar-12 12:26pm View
   
" because you cannot pass null reference."
According with the standard yes, this is "undefined behavior".
And since C++11 the stabdard says "it is an error to take the address of areference".
 
Butbefore that compilers allow do the trick:
<pre>
void fn(A& a)
{
if(!&a) cout << "null reference" <<endl;
else cout << a << endl; //admitting << works for A
}
int main()
{
A an_a;
fn(an_a);
fn(*(A*)0);
}
</pre>
 
This is not orthodox, but the concept of "null reference" could be defined.
Today anymore.
Emilio Garavaglia at 4-Mar-12 14:56pm View
   
I saw the thread and the way it was mostly misunderstood.
 
There's nothing bad teaching C, where C is required.
The bad thing is teaching C where C++ is required, sowing as "C++" what is just C.
 
Low level stuff is something that has top be known. The problem is "when".
Emilio Garavaglia at 4-Mar-12 12:19pm View
   
The point is that moTot has NO MEMORY associated with it.
You can:
- allocate when needed (but you have to delete it when no more needed ...)
- declare a return array in main, and pass it to be written as a third parameter (and not use the return value)
- return a class that manages the memory itself (like std::vector): thta's teh proper design, but frankly, with the teachers you have, doing the right way will be impossible.
Emilio Garavaglia at 2-Mar-12 2:06am View
   
FAT and NTFS have a completely different internal structure. "Converting" (I meam: "in place converting") is practically impossible. You will soon end-up in creating another volume, and move the files in it. But at that point, you just have to invoke the OS functionalities.
 
It's not calling a cat "dog" that make it barks.
 
Emilio Garavaglia at 27-Feb-12 15:09pm View
   
Yes, but those processes are launched by services, not by other user-level processes. If you're a a system extension, it's you hosting the user, but if you are a user process is the user hosting you. He has the full right to shut you down.
Emilio Garavaglia at 22-Feb-12 14:51pm View
   
Done!
Emilio Garavaglia at 18-Feb-12 11:04am View
   
Reformatted
Emilio Garavaglia at 17-Feb-12 9:14am View
   
Please don't post further question or messages to answer's authors as "solutions". Use the "have question or comment" button for that, otherwise the authors will not be notified of your requests.
Emilio Garavaglia at 17-Feb-12 2:19am View
   
The safest way is to declare all the operator new and operator delete variants you can find in <new> as inline function in one of your header and make sure your header is always included before any other. This will bypass whatever compiled version exist in whatever library.
 
Of course, your inlined version may just call regular function you can supp,ly in other modules.
In this way, whatever translation unit will not see your header will use the library one, otherwise your one.
 
But since STL containers are templates (and hence defined inline), STL will use both your function or the library ones depending if the CPP file you are compiling includes or not your header.
Emilio Garavaglia at 15-Feb-12 8:13am View
   
Deleted
Are you staring your objects in the map or just pointers ?
Emilio Garavaglia at 15-Feb-12 8:10am View
   
Did you overload new globally or as a member operator of your class?
Are you staring your objects in the map or just pointers ?
Emilio Garavaglia at 10-Feb-12 16:08pm View
   
Nope. Whatever virtual function remains virtual if overridden in a derived class. Dtors are not exceptions.
 
If the most inner base has a virtual dtor, all derived of whatever order will have one, even if you don't specify it as such.
Emilio Garavaglia at 10-Feb-12 2:11am View
   
"your classes should have at least one virtual method": that's typically done by making the root class having a virtual dtor.
Emilio Garavaglia at 6-Feb-12 2:41am View
   
What about setName?
Emilio Garavaglia at 3-Feb-12 2:29am View
   
You have to clarify some aspect of the nature of the problem.
 
An "image" (in common sense) is 2D (it can be a projection of a 3D scene), but a 3D image shuld be (for extension) a "cube of pixel". Is that what you mean? Do you have to compare two "cube of pixels", or just two view of a 3D scene?
 
Then, what does "compare" actually mean?
- Compare to look if they "are" the same (two identical copies).
- Compare to look if they "look" the same (apart trivial transformation, like clipping / shifting / rotating etc.)
- Compare to look if they "represent" a same scene / physical object
Emilio Garavaglia at 2-Feb-12 4:03am View
   
"No one should" means nothing.
 
Or it is "it is forbidden" or it is "it is allowed".
There are laws and license contract for that. And can be even different form subject to subject and from country to country.
 

The fact that a dump can be provided or not depends on how the license is structure. Saying NO-ONE in aphoristic way is an abuse. The world is not the same everywhere.
 
The VC6 license says that the license code cannot be redistributed. Not the CD itself (you could download it publicly and anonymously from MS sites: the problem is that the site is anymore shown in pubic claims: the OP was simply asking a way to reach that site).
 
Saying "This is a public forum where licenses are respected" is tendentious, especially if the OP was not asking to violate the licence.
 
Emilio Garavaglia at 2-Feb-12 2:16am View
   
"still not certain": so what are you talking about ?
Emilio Garavaglia at 1-Feb-12 15:23pm View
   
The CD and the license are unrelated. MS CDs are all the same, and license are codes given to individuals.
 
He's just asking for a copy of a medium no one still industrially produce.
Emilio Garavaglia at 1-Feb-12 4:43am View
   
The only thing I understand is a "racism" between my classes and the standard ones.
 
But both relies on the same core language using the same core features.
And both can be "well designed" (as both can be criticized).
 
The standard library itself was all but "standard" before the standardization process took place.
 
At that time was as set of classes written by someone. But since the where classes someone wrote himself (according to your concept) shouldn't be designed that way ...
If I have something that behave as a string, I have the full right to concatenate the same way. I'm just re-using a "well known pattern".
 
You advise (knowing nothing about who I am, or the OP is) is tendencious: "Leave that trouble to STL and 3rd party numeric library provides and spend time on your core busines instead". My be my business is writing those libraries!
 
Also consider the "learning curve": if writing a class (considering also the time to test it) takes less than learning how to use a 3rd partly library, where is the trade-off? The answer is all about simple and trivial!
Emilio Garavaglia at 1-Feb-12 3:07am View
   
Andi, please... Stop coding C++ and use just only Java.
 
Having a type other then integer that is subject to integer arithmetic is normal if you need a numeric type that doesn't intermix with the other and can overload differently.
 
About + for concat(), do you know that std::string use + just forn that? If you think STL is somehow stupid, lieave away C++. Otherwist try thinkibng differently.
C++ programmers know operators are overridable, and know c=a+b is a generic expression that is not necessarily the assignment of the result of an arithmetic addiction. Please open your mind (and mindset!)
Your concept of "professional large project" is based on C++99 state of art.
Emilio Garavaglia at 1-Feb-12 2:50am View
   
Where do you handle WM_PAINT ?
Emilio Garavaglia at 31-Jan-12 13:07pm View
   
That's not an easy answer, without a knowledge of what they are for.
 
In general I avoid using my own lists in favor of std::list (unless the "list" is intrusive in respect to components). But it's not a response for a comment. There can be articles on that subject.
Emilio Garavaglia at 30-Jan-12 2:49am View
   
May be it is configured to not respond, or may be the network port it is attached to filer them.
Or may be its network interface is misconfigured respect to the network segment it is attached to...
Emilio Garavaglia at 30-Jan-12 2:38am View
   
I started considering the user's choice does not depend ONLY on that.
May be shared_ptr is used because the A objects are not only forming a chain (in that case killer will not kill anything: will just let the object with one reference less).
 
If the problem was just "chaining", than unique_ptr will suffice.
An if the polymorphic deletion of STL smart-pointer is retained too costly, a regular pointer into A with proper move semantics will be at the minimum cost.
Emilio Garavaglia at 29-Jan-12 12:25pm View
   
Without any idea of th network topology and related configuration whatever thing can be possible
Emilio Garavaglia at 25-Jan-12 2:37am View
   
Good links, but we must warn the OP that analyzing packets requires first the packets to be analyzed to flow into the observer wires. That's not only a matter of "code" but also of network topology and functionality. A switched network, for example, will not send packets to machines other then the destination, hence you'll not see any of those packets (unless modifying the network configuration to replicate the packets to you as well)
Emilio Garavaglia at 24-Jan-12 15:32pm View
   
retagged as C++/CLI
Emilio Garavaglia at 24-Jan-12 2:55am View
   
That's exactly my point: it is not a problem for newbie. If you know all the required concepts the solution is almost trivial. If you don't, you will never learn them from that problem: there are too many basic concepts contemporary interleaved, that cannot be figured out individually if you never met them individually before. Teachers that toss newbie into that problem are escaping from teaching!
Emilio Garavaglia at 23-Jan-12 10:03am View
   
Good points!
Emilio Garavaglia at 21-Jan-12 13:14pm View
   
I will be an impossible task, since it can be demonstrated it is not MT-decidable.
 
Parsing can detect SOME potential leak sources, but there are other that can be proven only at runtime, and other that cannot be proved at all.
Emilio Garavaglia at 19-Jan-12 8:29am View
   
HTML re-encoded
Emilio Garavaglia at 18-Jan-12 11:15am View
   
At least red the link I posted ...................
If I have 20 nested loop I have to go out (Please don't focus to the number 20: I can say 2 with exactly the same consequence), nesting into function to use exception is just another way to do the same thing.
 
Admit that goto is there for a reason: There are problem domains where things cannot be decided into a pre-given set of strictures, whatever the set of structure is. It not a problem of "code readability" but of computation theory.
 
I can write a program with no if-s, just for
It will be certainly unreadable. But that -to me- it's not a good reason to bash for (or if), but to bash a bad structure choice.
 
The same is true for goto-s.
Instead of bash goto, look how the same code looks like without, then decide what reads better.
Believing or not, there are problem domains (most likely not the one you and Djiksta worked on...) where goto looks better.
The fact you didn't ever encounter them doesn't make them nonexistent.
Emilio Garavaglia at 18-Jan-12 4:38am View
   
Johny, please, at least READ THE LINK I posted down-to the end.
 
I know about the use of flags, and I spoke of it in my comment as well (so what is your comment adding?)
 
But I also know that the use of 20 flags is worst than the use of a goto.
 
That said, I perfectly understand your point. But please also understand that there is not "science" behind that. Just only a matter of TASTE! (and please also understant my post was in answeer to Jack, not to you!)
 
It is true that a BAD use of GOTO can lead to unreadable code, but this fact is tautologically true for whatever statement, logic, or programming pattern you want / like to invent.
And that's not what I was talkmig about
Emilio Garavaglia at 18-Jan-12 3:06am View
   
The reason why goto is there is that the only way to code a finite state machine without introducing fuzzy logic to bypass it.
 
There are no devils, loki or whatever religious reasons. Just well precise technical reasons.
 
Goto is the only readable way to escape more than one block (have you ever need to escape from two nested for loops? For one you have "break", for two you can either introducing a meaningless variable to force the exit condition or use a goto. There are entire programming school that consider the first practice more harmuful than the second.
 
Please stop blaming goto without reasons.
In these context goto-s are fine. The problem is a misuse of break statement in the switch.
 
If you are interesten in a more neutral analysys of what goto-s are for, read this: http://david.tribble.com/text/goto.html
Emilio Garavaglia at 14-Jan-12 13:53pm View
   
"In this case the compiler can optimise the statement to an existing constructor (String(char* str)), because the creation and assignment happen together."
 
That's not corect: the standard REQUIRES that the = after a declaration introduce an initialization, hence it is not an assignment.
It is not something the compiler CAN do. The compiler MUST do that way.
Emilio Garavaglia at 14-Jan-12 13:50pm View
   
Carlo, it is not an optimization: the standard explicitly says that the = after a declaration is "initialization", not "assignment", and hence the constructor is called. It is not "creating an empty string and then change it by give it an 'a', but "create a string that 'is like an' 'a' ".
Emilio Garavaglia at 14-Jan-12 13:39pm View
   
This is not a question.
Emilio Garavaglia at 7-Jan-12 13:16pm View
   
:-O
Emilio Garavaglia at 25-Dec-11 5:26am View
   
removed the C++ tag
Emilio Garavaglia at 25-Dec-11 5:20am View
   
SubString is not C++ (at least C++/CLI)
Emilio Garavaglia at 16-Dec-11 5:27am View
   
It seems to me you did not understood my "scope".
 
VC6 is NOT a STANDARD C++ compiler. It misses to match certain language specifications. This is a fact, not an opinion.
 
If you have to LEARN C++, VC6 cannot be a "reliable tool" since it teaches you something that's NOT (strictly speaking) C++.
 
If you have to WORK on an an existing product developed with VC6 using its non-standard features then you have to use VC6 (and that's why it is still used by lot of people).
 
But the two scopes an purposes are different. It's not a matter of obsolescence, but of what are you going to learn. VC6 is NOT C++. Once you know that, decide depending on what you need. But deciding assuming VC6 is a proper C++ implementation is dangerous, since may lead to a wrong decision because of a lack of information.
Emilio Garavaglia at 16-Dec-11 5:15am View
   
To me, it worked!
Emilio Garavaglia at 16-Dec-11 2:38am View
   
Anna, you should have been post this as a solution, not as a comment. Can you delete it and resubmit it in the "solution" box?
Emilio Garavaglia at 16-Dec-11 2:35am View
   
It's 2011 (almost 2012) VS6 is not (anymore) a C++ standard compiler, and has wrong support (different from no support) for many things. It should not be used as a "leraning tool".
Emilio Garavaglia at 15-Dec-11 12:59pm View
   
"Perhaps for many programmers coming out of school today,..." Good question, it depends on the school.
 
By my personal experience, programmers comes from two types of school: engineering and computing science.
The first start study the computer as a system (a finite state automata) then abstract systems over systems. Touring equivalence is a consequence, and languages equivalence is for them clear from the beginning (they typically start programming controllers machine code). Mastering a language is understanding a proficient way to build product and tools with it. Paradigm (like OOP) and patterns (like composite-visitors) are just "formalization of good common sense" (I understand certain pattern are known with certain names after years of usage of them my own).
The seconds start studying "computing" (not computers) as a formal way to express algorithms. Pattens and paradigms are tough as formalisms, Touring equivalence is tough as a mathematical theorem, and the existence of physical machines that mimics a given language is... postulated.
Until they don't see the correspondence with the physical word, a certain level of ... magic is perceived. For engineers, the "magic" is, instead, their capability in hiding the "tricks".
Emilio Garavaglia at 15-Dec-11 10:14am View
   
It the Touring equivalence is valid, everything you can invent is... syntactic sugar for an if/goto that is what -as an ultimate analysis- what the CPU finally does.
 
Big switches are replaced by virtual functions, and where virtual function cannot apply (like in object construction) with map dispatching. And map dispatching can be implemented in various ways, via std::map or via template specialization or "static fabric objects". But everything, given your state point, will always noting more than the "distribution of the switch".
 
The point is how the switch is maintainable and extendible either from the inside (by changing it) or the outside (adding elements in a time other than the "switch" development)
Emilio Garavaglia at 14-Dec-11 11:00am View
   
""Round rectangle" is oxymoron...."
In plain English yes ... in MS-APIish no: http://msdn.microsoft.com/en-us/library/aa929212.aspx
Emilio Garavaglia at 14-Dec-11 10:34am View
   
ahem ... not properly a question for a QUICK answer: it's more or less like "I have a screwdriver and a car. How can I fix the engine"?
Emilio Garavaglia at 6-Dec-11 7:42am View
   
Because there is a difference between vector and list.
Vectors are meant for "by end growing" and "random access by index", while list are meant for "random insertion" and "sequential access". There is no operator[] in list-s.
 
Jut read about std::vector and std::list documentation!
Emilio Garavaglia at 6-Dec-11 4:33am View
   
beware to certain "exercise": there are many dirty ways to correct them, but may go to "bad coding".
 
For example: cin and getch() can mess each other (one is buffered, the other not, and the first may use the second internally ...) and shouldn't be mixed up without cares.
 
Another example: while(cin>>x[i]){i++} reads until there are readable numbers than blocks. But doesn't take care about the size of the x array!
To track that you have to rewrite most of the logic (there is nothing in the cpde doing it). But C++ has classes (like std::vector) that can manage by their own dynamic sizes.
 
Despite the number of errors in logic, it looks code coming from an OLD and outdated bad book!
Emilio Garavaglia at 6-Dec-11 2:31am View
   
fixed an HTML spurious tag
Emilio Garavaglia at 2-Dec-11 15:47pm View
   
I am lucky there was no Internet at all!
Emilio Garavaglia at 29-Nov-11 13:13pm View
   
If there was an universal way, anyone would have any existing credit card number!
Emilio Garavaglia at 29-Nov-11 13:12pm View
   
Deleted
If there was an universal way, anyone would have any existing credit card number!
Emilio Garavaglia at 23-Nov-11 9:48am View
   
neither the corner or faces: n[3][3][3] has 27 elements... one of them is in the middle of the cake!
Emilio Garavaglia at 20-Nov-11 10:32am View
   
"have you ever used procedural programming language???"? Yes: C and FORTRAN, as I used LISP (functional) as I used COBOL, Smalltalk, C++, D etc.
And I programmed "objects" (in real OOP sense) with plain C, with proper usage of compilation separation and opaque types.
There are languages that are fundamental agnostic to the programming technique (C, C++ and D fall in this category) for which their standard library pushes a philosophy (iostream are OOP, containers are generic, ...)
There are languages (like C# or Java) that are created around a well defined programming technique (OOP, in that case, functinal for LISP etc.) for which every problem you want to solve must be solved through that only technique (even if not efficient at all). As a consequence, marketing was forced to push on that convincing abut a presumed "superiority" that -in fact- is not intrinsic as they want it top appear.
Emilio Garavaglia at 19-Nov-11 13:50pm View
   
OOP Object concept is not "real world". Just a (in the sense of ONE OF) model of it. The concept of "separated module" does not require necessarilly OOP, and re-usability is not a direct consequence of OOP (a badly designed mess of entangled objects is all but reusable)
Generic programming is not OOP. It can be used in OOP, but it has its own definition, and does not necessarily relates to objects.
 
The most of these arguments belongs much more to the OOP mythology, than technology.
Emilio Garavaglia at 18-Nov-11 2:42am View
   
This sounds suspicious.
It is your application, but it is not you computer.
Let the computer owner to decide what he has to to with his own folders.
Emilio Garavaglia at 14-Nov-11 15:11pm View
   
Computer don't have "psychology". I does not metter what you "just want to do" (oh ... my innocent little baby!). It does matter what ANYONE CAN DO if the OS made what you "just want to to" possible. Virus writer will loooooooooove it soooooo much!
Emilio Garavaglia at 10-Nov-11 13:23pm View
   
You can start from here:
http://www.relisoft.com/book/web_preface.html
Emilio Garavaglia at 7-Nov-11 2:55am View
   
The question was about the new operator. My reference to the stack was just because the user did not intentionally (looks like a user coming from C# or Java: he uses pointers every time without knowing it!)
Emilio Garavaglia at 29-Oct-11 15:32pm View
   
What do you mean with "compare"? Do you want:
a) compare the words I'm saying with the words that have been said before or
b) compare my voice characteristic with the one you know to be sure I'm the same person?
 
If the problem is a) what you need is to translate all voices int otext and compare text. Comparing the sound waves is clueless: whatever you may say and repeat, is never the same wave. What you hear (or better, what your brain interprets) is the variation of the spectrum, not the direct floating of the air.
Emilio Garavaglia at 12-Oct-11 3:44am View
   
If you sniff on a switched network, where no span has been configured, you get only broadcasts and unknown destinations.
 
If you see a flow, you can resemble them by taking packets belonging to the same sorce-address&port-to-destination-address&port quartet by sorting in respect to their sequence.
But that "flow" may be its not a "flow of data": depending on what the application is, may be the flow of its own session protocol (eventually including data) ...
Emilio Garavaglia at 12-Oct-11 3:39am View
   
The saved document and the printed document have different data format, so the size may be very different. please clarify your question.
Emilio Garavaglia at 4-Oct-11 2:57am View
   
That's exacly how the standar C++ shold deal with number representation: replace the num_put / num_get facet of the locale.
Emilio Garavaglia at 3-Oct-11 7:50am View
   
It is clean that you didn't even understood what I said.
Re-reat my post carefully: I never told you to remove it
Emilio Garavaglia at 3-Oct-11 7:48am View
   
No. Dynamic cast are the way to go, but you cannot assume they succeed. So first do the cast, and if the result is not null, access the members. Again: you are confused on what dynamic or static cast actually do and try randomly to use one or the other until you find something working. Stop smoking marijuana, stop ingesting ecstasy pills, stop injecting amphetamine.
 
STOP coding randomly.
 
Calm down two days, then sit down and study the concepts and test the concepts one by one (and forgot your project) with small and clean checks. Come back to your project when you have fully understood them. You're now trying to do something that is 10 times bigger that your actual knowledge.
Emilio Garavaglia at 29-Sep-11 16:49pm View
   
Sure: you can always do better. My point is that there are case where is not just a matter of "find and replace". What you are in fact proposing in your comment is a (sort of) "rethinking", not just a syntax adjustment.
The fact that such a rethink is "convenient" depends case by case, and it's not always obvious.
Emilio Garavaglia at 29-Sep-11 10:25am View
   
Of course, 90% of the cases it is.
But there are cases (especially for thing that work closely to the hardware) that interpreting a given bunch of byte (because, despite what language layers and guru can say, that's what the hardware gives you) sometime as a struct, sometimes as another is the only way to go, since that's the way the underlying hardware works.
I agree that is not C++ "good style": it is -in fact- "good old bad C hack" but is what makes the interface to underlying operating system to work.
If you are in one of these situations, considering C cast bad becomes considering low level abstraction bad. It depends on which abstraction level your code sits on.
Emilio Garavaglia at 28-Sep-11 8:01am View
   
Added a missing 0 ;-)
Emilio Garavaglia at 26-Sep-11 8:25am View
   
It changes almost nothing. The fact the FTP server is working doesn't demonstrate the HTTP server is also working, and the presence of a network device between the client and the server makes the two not sharing the same physical problems.
HTTP runs on TCP that correct congestions or packet loss with the timing I told you.
 
In general is a bad design target to very specific environments (if your network will be modified, your application may stop working with no apparent reason ... Good design should be prepared for the general case and eventualy optimize the specific one), unless you are on a very embedded situation where the network itself is also constrained.
Emilio Garavaglia at 25-Sep-11 4:06am View
   
When posting question about school and instruction don't forget to tell us where are you from.
School years are not the same all over the world, and school titles don't necessarily match exactly one over another.
Emilio Garavaglia at 22-Sep-11 3:38am View
   
"I'm afraid to say, by some long if statement."
Not to mention a map between strings an functors! ;-)
Emilio Garavaglia at 22-Sep-11 3:34am View
   
This is not "learning". This is "flooding" your brain with noises and confusion.
Yore gonna get your brain cell burned. STOP TO DRUG.
Start from the basics and follow tutorial in order. There is order on things, not just a random mess if informations (whose physical name is entropy).
Emilio Garavaglia at 22-Sep-11 3:34am View
   
Deleted
This is not "learning". This is "flooding" your brain with noises and confusion.
Yore gonna get your brain cell burned. STOP TO DRUG.
Start from the basics and follow tutorial in order. There is order on things, not just a random mess if informations (whose physical name is entropy).
Emilio Garavaglia at 22-Sep-11 3:17am View
   
replaced < > and removed spurious tags
Emilio Garavaglia at 18-Sep-11 12:52pm View
   
Don't post fake answer. If you want to reply to someone use the "Have a question or comment?" below his own post.
Emilio Garavaglia at 18-Sep-11 12:49pm View
   
This answer is misleading and claims a false concept.
Calling a constructor just creates a temporary object.
The problem is that a temporary object cannot be give to a non-const reference.
Emilio Garavaglia at 18-Sep-11 12:41pm View
   
Philippe is right: according to the standard, you cannot bind a temporary to a reference, but only to a const-reference.
It is a well-known "Microsoft specific behavior", that non-microsoft compiler developer simply call "bug" (working differently than specified).
Emilio Garavaglia at 14-Sep-11 17:12pm View
   
Yes, and a good lecture.
Emilio Garavaglia at 14-Sep-11 15:27pm View
   
retagged
Emilio Garavaglia at 14-Sep-11 7:55am View
   
yes: this one comes from the teacher! :-)
Emilio Garavaglia at 14-Sep-11 7:54am View
   
corrected a broken link
Emilio Garavaglia at 12-Sep-11 2:35am View
   
Please use "improve question" and provide more informations.
What you wrote is so vagues and general that cannot lead anywhere.
Emilio Garavaglia at 10-Sep-11 2:56am View
   
"Horse is really around the corner": ??? My reference culture does not contain such an expression. What does it mean? (Of course, that's off-topic, do not answer if you find that's not the case!)
Emilio Garavaglia at 9-Sep-11 2:30am View
   
< and > replaced with &lt; &gt;
Emilio Garavaglia at 9-Sep-11 2:20am View
   
removed spurious html tags
Emilio Garavaglia at 8-Sep-11 12:53pm View
   
May be: Just try to update the MinGW from here: the automated installer will download a last version of the tools.
 
Download them in a new directory, than swap the new and the old ones.
Emilio Garavaglia at 8-Sep-11 2:36am View
   
"is there a difference between 1 greater than sign on the end and 2 greater than signs?"
 
Yes, the second was a typo (fixed)
Emilio Garavaglia at 7-Sep-11 12:32pm View
   
retagged as C++/CLI
Emilio Garavaglia at 6-Sep-11 9:32am View
   
Yet another chicken and egg problem ...
Emilio Garavaglia at 6-Sep-11 2:25am View
   
Retagged as SQL
Emilio Garavaglia at 6-Sep-11 2:23am View
   
The tag is C++, not C++/CLI
Emilio Garavaglia at 6-Sep-11 2:20am View
   
If that's the case, just use UDP as a transport protocol, and use 255.255.255.255 as a "destination address".
I have in any case to insist: even in a LAN, all broadcasts a received by all the system in the network (including the ones not interested in them).
As the network grows, the number of broadcast increase and so the number of interrupts all processors will receive, resulting in broadcast storm and global poor performance.
Only poor configured networks work the way you described.
 
Any way, i you have to work with SNMP, the "source" is here:
http://www.net-snmp.org/
Emilio Garavaglia at 31-Aug-11 5:34am View
   
If you want better help, ask better your question: we don't see your screen and don't read your mind:
- Where does CWinThread comes from ?? MFC ?? your own class ?? At least give some hint on the environment and libraries you're using.
- where are m_pThread and m_hevent declared? Are we inside a method of a class? Are they members of such a class? Are they initialized at some point ?
 
Use the "improve question" link and edit your question to make it more self explaining.
Emilio Garavaglia at 31-Aug-11 5:28am View
   
...when I send a ping any machine in the domain that I get that does not reach the machine, then rises and network services, but as I can do to locate or can get the domain....
 
Sorry, but ... I'm totally lost in your wording!
Can you reword and use better punctuation, making your question more comprehensible?
Emilio Garavaglia at 30-Aug-11 10:49am View
   
Nice. How are those two things related ?!?
Emilio Garavaglia at 30-Aug-11 10:48am View
   
Deleted
Nice. How are those two things related ?!?
Emilio Garavaglia at 30-Aug-11 7:42am View
   
Is there a default push-button in your dialog?
Emilio Garavaglia at 26-Aug-11 11:39am View
   
Thanks to let me know.
Consider also as an alternative to hooks, subclassing
http://msdn.microsoft.com/en-us/library/ms633570%28v=vs.85%29.aspx#subclassing_window
Emilio Garavaglia at 26-Aug-11 9:01am View
   
Oh, nice. Not perfect (but perfection in these cases is always subjective) but now it is anymore conceptually wrong!
 
(Rating adjusted!)
Emilio Garavaglia at 26-Aug-11 5:02am View
   
Dear mbue, this is not a "longest piss context".
Do you understand that the way you used constructors here is WRONG and that posting this solution here to a student that that trust your expertise may cause him problems?
This solution should be deleted because misleading!
 
It is true that the tags are both C and C++, but what you did is neither C nor C++
Emilio Garavaglia at 26-Aug-11 2:57am View
   
It's not C++. It's C. It works because is very good C skill, with a very few of C++. Your code is 80% C, 20% C++. Your very good skill must be re-proportioned to 20% of weight.
The way you use constructors is WRONG not because I said it, but because the C++ language specifications said that. It works only because the compiler you used was "permissive". That practice, if used with more complex objects, may result in double allocation/creation of leaked resources.
So, please, stop LOL-lling (There is absolutely nothing to laugh here) and study the language specification.
 
Consider this as a refuse to hire.
Emilio Garavaglia at 25-Aug-11 4:11am View
   
This solution is C++ed C#, with a lot of plain C. Not C++
#defina max is ridiculous, there is std::max, that is a function (not a macro!)
Constructor cannot call each other explicitly (it's a feature introduced with C++0x, but doesn't work the way you did: see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf.)
Use of malloc/realloc is an history relict. There are std::vector for dynamic containment.
I can continue, but frankly, before posting this things as a solution, dust off your C++ skill!
Emilio Garavaglia at 24-Aug-11 13:48pm View
   
The problem is the way you are approaching the problem is wrong. There are many solution, but all of them presume to completely rewrite your code (that look as a random messing-up of not understood concepts). A more proper approach is: you want to process HTML, but this requires understanding of networking, socket programming and string manipulation. Ok. Now forgot HTML for a while, and start studying those concept one by one with example proper of their own domains. Study how C++ handle and manage stings. Study how C++ handles I/O. And you will discover you have to understand operator overloading and templates. Stop a while, and start from them. Then pass to the C++ standard library: strings, I/O, containers and iteration. Then study the HTML specs. Only at that point start working on it. Whatever other help is misleading, and will give you even more confusion. Ha... also understand that C++ is not C. Whether it can call old C functions, there are better and more robust way to do certain things. Forget printf: C++ I/O is different.
Emilio Garavaglia at 24-Aug-11 13:47pm View
   
Deleted
The problem is the way you are approaching the problem is wrong. There are many solution, but all of them presume to completely rewrite your code (that look as a random messing-up of not understood concepts).
 
A more proper approach is: you want to process HTML, but this requires understanding of networking, socket programming and string manipulation.
Ok. Now forgot HTML for a while, and start studying those concept one by one with example proper of their own domains. Study how C++ handle and manage stings. Study how C++ handles I/O.
And you will discover you have to understand operator overloading and templates. Stop a while, and start from them.
Then pass to the C++ standard library: strings, I/O, containers and iteration. Then study the HTML specs. Only at that point start working on it.
 
Whatever other help is misleading, and will give you even more confusion.
 
Ha... also understand that C++ is not C. Whether it can call old C functions, there are better and more robust way to do certain things. Forget printf: C++ I/O is different.
Emilio Garavaglia at 23-Aug-11 10:13am View
   
How doe you "instantiate it with a boolean" ??
Emilio Garavaglia at 19-Aug-11 5:44am View
   
what are set and get ? I see no declaration for them.
Emilio Garavaglia at 17-Aug-11 6:25am View
   
How did you get the TCP packets?
 
You are probably operating at the wrong abstraction level.
Resembling of TCP packet should be in charge to the socket library.
You should not deal -at application level- with transport protocol details.
You should just see a stream of characters.
Emilio Garavaglia at 13-Aug-11 6:08am View
   
The server must also behave as a "multicast router", running a multicast rouitng protocol, and the clients participate in the routing protocol through your VPN interface.
Emilio Garavaglia at 13-Aug-11 5:58am View
   
There's no "right way". There is the C++ way, the C# way, the D way the VB way ... . What matters if name for A changes?? It depends on how many "changes" you have to track and how many of them may exist you're even not aware of. It is something that relates to the "industrial coding" and software maintenance. It is a common opinion between industrial coders that C++ has limitations in this field.
Emilio Garavaglia at 13-Aug-11 5:57am View
   
Deleted
There's no "right way". There is the C++ way, the C# way, the D way the VB way ... .
What matters if name for A changes?? It depends on how many "changes" you have to track and how many of them may exist you're even not aware of. It is something that relates to the "industrial coding" and software maintenance.
It is a common opinion between industrial coders that C++ has limitations in this field.
Emilio Garavaglia at 12-Aug-11 2:17am View
   
but this->i remain the same even if you have to change the name of the class.
class::i doesn't.
There are language (D is and example) where even constructor and destructor are not name Class()/~Class but this() and ~this().
It is the old plain language use or pronoun versus nouns.
Emilio Garavaglia at 11-Aug-11 2:14am View
   
Saying "but it didn't worked" without saying WHAT and HOW didn't worked, how you did it and what you've instead got, will simple keep people away from this question, with very few chances to get an answer.
Emilio Garavaglia at 9-Aug-11 6:09am View
   
My vote of 1:
The answer citation is corret, but the conclusion is misconceived.
main() can stay in a library as wel, not necessarily between the user sources of an app.
 
Just find main() in an MFC app, for example!
Emilio Garavaglia at 6-Aug-11 2:59am View
   
Actually Cristian has one point: you post is tagged as C++, but what you did is plain C. There are better standard ways to create and concatenate strings in C++ that don't suffer the memory allocation, based on std::string and std::sstream.
If you really want C (because you are required to do so), tag yoyr question as "C" (not C++), otherwise try to improve and understand the C++ way, instead to stay in "C compatibility mode".
 
Emilio Garavaglia at 5-Aug-11 12:46pm View
   
Of course, I learned C before C++ because ... there was no C++ at the time I learned C. (In fact, there was even not Windows or DOS! My first programming environment was an AT&T UNIX IV machine!). But what I'm saying here is a statistic based on how programmers coming from different experience evaluate their own skills.
From that, it seem that who started directly from C++ (in proper way: with strings, container, iterator etc. not by emulating C) is more "broadened" than who started from C (that tends to approach everything as OOP where OOP is a way to group functions, and almost misses the generic and functional aspects) who takes more time to reach the same knowledge level.
 
Just give a look to the newbies question about C++: why the most of them are related to array uses as string a-la plain C?
Instead of profiquently use C++, they approach everything procedurally, missing all the reason C++ come to existence. Why?
To me the answer is simple: the most of "trainers" learned C before C++ and, although now fluent in C++, didn't have elaborate yet a way to communicate their notions.
Emilio Garavaglia at 5-Aug-11 2:54am View
   
simple and to the point.
I voted 4 (not 5) since this is C, not C++.
Emilio Garavaglia at 4-Aug-11 8:19am View
   
I was tempted to answer "by reducing to 1/2 the distance from the monitor ..." :-))
Emilio Garavaglia at 3-Aug-11 16:27pm View
   
It is not called by the "program loader", but from the program initialization routine whose name is defined in the linker configuration (the default for Micorsoft linkers is mainCRTStartup).
It calls all global object constructors, then main, then the local static destructors, then the global object destructors.
Emilio Garavaglia at 3-Aug-11 16:22pm View
   
Unfortunately yes.
The point is that C++ is not "pure OOP", not "pure generic" not "pure procedural", not "pure functional".
If you try to be zealot on one of those paradigms, you find "dirtiness" because of the bridges towards the others.
Emilio Garavaglia at 3-Aug-11 15:51pm View
   
cleaned up formatting
Emilio Garavaglia at 1-Aug-11 2:31am View
   
If you want to take advantage by a forum don't post generic comment like "It doesn't work".
Tell EXACTLY WHAT didn't work, what was the wrong result you get and what you wold expect.
Emilio Garavaglia at 28-Jul-11 3:55am View
   
You tagged as C++ but what you speak about is C++/CLI.
Are you using the wrong library or just did a wrong tag ?
Emilio Garavaglia at 27-Jul-11 12:59pm View
   
Christian, since you got that you got it wrong (gulp!), ... delete this to avoid confusion!
Emilio Garavaglia at 27-Jul-11 9:08am View
   
C++ "crude and naked" no, but with some support like boost::spirit may be easy.
Emilio Garavaglia at 27-Jul-11 4:39am View
   
I can vote 1 to compensate :-)
But you don't deserve it!
Emilio Garavaglia at 27-Jul-11 4:38am View
   
There is no concept of "reference type" and "value type" in C++.
struct and class are the same (except for public vs private default member visibility)
Emilio Garavaglia at 27-Jul-11 3:11am View
   
Sure, but it is much more a matter of "convention" then substance.
OOP define what inheritance is. C++ provides a "tool" named class inheritance. Incidentally that was the only tool available in the first C++ standardization, and this made C++ programmers thinking the two concepts (defined independently each other and only partially isomorph) where the same. More tool had been added but ... the dear old convention survive.
There's nothing bad in it. Simply we must know it is a convention, not a physics constrain, making everything else impossible to exist.
 
I can define "objects" even with plain C struct-s containing function pointers, and inheritance as "responsibility chain".
Not something any "conventional" book on OOP will ever do, but technically getting the same result.
Emilio Garavaglia at 25-Jul-11 13:00pm View
   
The point is that C++ is not a "strict OOP language". Inheritance makes sense if combined with polymorphism (otherwise is half-a-machine), but C++ has both runtime polymorphism (based on inheritance, that fits Santosh answer) and static polymorphism (based on template recursion & specialization, and policy driven classes) that is not necessarily based on base-to.derived inheritance, but still allow a clas to inherit something from another. And this -although existent- is not reflected in the proposed answer. The OOP concept of inheritance fits different programming formalism. C++ inheritance is just one of them. C++ embedding and delegating plays the same external effect. So, my point is: it depends if the word "inheritance" is meant to identify the way the object is internally made up (using class inheritance) or the way the object externally behave (exhibit the behavior of something else plus something more)
Emilio Garavaglia at 25-Jul-11 13:00pm View
   
Deleted
The point is that C++ is not a "strict OOP language".
Inheritance makes sense if combined with polymorphism (otherwise is half-a-machine), but C++ has both runtime polymorphism (based on inheritance, that fits Santosh answer) and static polymorphism (based on template recursion & specialization, and policy driven classes) that is not necessarily based on base-to.derived inheritance, but still allow a clas to inherit something from another. And this -although existent- is not reflected in the proposed answer.
The OOP concept of inheritance fits different programming formalism. C++ inheritance is just one of them. C++ embedding and delegating plays the same external effect.
So, my point is: it depends if the word "inheritance" is meant to identify the way the object is internally made up (using class inheritance) or the way the object externally behave (exhibit the behavior of something else plus something more)
Emilio Garavaglia at 24-Jul-11 12:39pm View
   
In strict C++ terminology you're right.
In more generic terms, the OP may be right too.
In generic programming, two classes with a same interface one of which is implemented by means of the other can be said it "inherits" the other functionality. That's plain English, after all.
Emilio Garavaglia at 22-Jul-11 12:06pm View
   
I got your point (my answer is equally rhetorical ...)but for the problem you pose there cannot be any "programming workaround", since it relates on the fact that the hardware doesn't have the concept of "mouse cursor": it is just a picture the software draws on it. And that conflict with any other software drawing on it!
Emilio Garavaglia at 22-Jul-11 3:50am View
   
You are misinterpreting the meaning of "routing".
The line you wrote, literally means:
"send all packets directed to 124.151.99.22 and it alone (MASK 255.255.255.255 means just that) to 192.168.1.253
 
Is not related to the packets you receive, but to the answers you eventually reply to it. IP routing is destination directed (not source!).
The fact it is a black hole or not, then, depends on what 192.168.1.253 actually is into your network.
Emilio Garavaglia at 19-Jul-11 5:00am View
   
It depends on what you're going to use that file. It can be a binary dump, a textual form, a compressed encode...
Elaborate much more your question
Emilio Garavaglia at 19-Jul-11 4:56am View
   
So why hide it?
If workers are "monitored" they should know, otherwise they are "spied".
Emilio Garavaglia at 17-Jul-11 4:32am View
   
... and even in that case, the user can always ... break the disk!
Emilio Garavaglia at 14-Jul-11 2:52am View
   
Every time you've to create something for somebody-else use you have to choices: dynamic allocation (so that what you create will survive the scope boundaries) or copy-on-return. The problem with arrays is that the compiler doesn't do that automatically since in general inefficient.
 
But for relatively small arrays, if you wrap them into a struct
(like struct ten_ints { int ints[10]; }; you get something that can be copied, so that you can do ten_ints z; return z; and be even more efficient than a dynamic allocation/deallocation that may result in processor page fault in caching. With modern processors, the tradeoff if around 500 bytes.
Emilio Garavaglia at 14-Jul-11 2:28am View
   
Good point addressing also the last OP question.
Emilio Garavaglia at 11-Jul-11 10:25am View
   
unfortunately, it is not a matter of experience. Simply, the system is not designed to work that way.
Emilio Garavaglia at 11-Jul-11 2:41am View
   
The concept is weak. Security relates to keys, not to algorithms. There can be a standard like there is a standard for encrypted communications (IPSEC). Simply there is not enough "critical mass" for such exigence to lead to such a standard. The standardization effort will be higher than rolling your own way.
Emilio Garavaglia at 7-Jul-11 8:09am View
   
Don't post reply as "solution". The guy you are replying will not be notified.
Emilio Garavaglia at 7-Jul-11 8:08am View
   
From the OP.
Oh,I remember the 3d max.
You know use 3d max 7?
in 3d max 5,you have to manually unwrap
3d max 7 has UV unwrap.I can unwrap as 3d max ?
give me an idea or code
thank you
 
giatuan2011387
 
Emilio Garavaglia at 7-Jul-11 2:58am View
   
between EXE/DLL-s yes (well: not properly a "leak": most likely an inconsistent allocator internal state). Though a completely static linking no. I asked to know what did he tried just to understand what situation should apply.
 
The problem is in the question: he asked "how". But the point is that, in certain situations, cannot be done.
Emilio Garavaglia at 7-Jul-11 2:19am View
   
It depends of how smart is the compiler implementation. Checking if a supposed derivation is true just requires a comparison of vtable POINTERS (not tables!). That's the same as comparing integers.
Emilio Garavaglia at 7-Jul-11 2:13am View
   
From english to italian to latin to french to english: "occuration" == "happening". (an ancient roman is probably still walking around!)
Emilio Garavaglia at 6-Jul-11 15:28pm View
   
The idea is not itself bad, but it is just "reinventing RTTI", that is already part of the language.
Just give to base a virtual method (a do-noting virtual destructor is enough) and let dynamic_cast check if a pointer can runtime become another or not.
It gives identical result, but let the compiler able -if it is- to optimize out the whole structure.
Emilio Garavaglia at 6-Jul-11 12:41pm View
   
If the library is static, the problem is mostly in the compile / link order.
If the library is dynamic (or linking a dynamic library) you shouldn't do that, since the two function may not be sharing the same global variable space (the "new" function, returnn the pointer but also tracks what it returned in a global data-structure that "delete" must update consistently. But if the two calls are in different DLL, there maybe two different copy of those global structures, one faced by new and the other by delete, that "see" a call about something it doesn't know it has been allocated.
Emilio Garavaglia at 6-Jul-11 5:01am View
   
:-))) An Italian comic said (about statistic) "If you have your head in the oven and the ass in the fridge ... you're not likely in-average well!"
(of course, you can swap the "terminals" ...)
Emilio Garavaglia at 6-Jul-11 4:54am View
   
Not necessarily. HDLC is a standard communication protocol. Same open implementation may exist.
Emilio Garavaglia at 4-Jul-11 8:18am View
   
Not efficient, but elegant!
Emilio Garavaglia at 4-Jul-11 3:49am View
   
What does it mean "You just need to give it the needed resources"?
Do the right comparison with the SAME resources! Otherwise whatever thing we may say is true!
Emilio Garavaglia at 3-Jul-11 5:56am View
   
Java is not for performance, C++ is not for "opennes", especially if used close to the hardware. Gui can even be none of the two, but a HTML/XML browser app, driven by a C++ server socket. I probably code the core as C++ module, with a plain C interface, to be linked by other modules, written in whatever language is suitable to make the job done. A QT based C++ gui is fine (but .. hey .. that's not "pure C++", there is lot of other scripting translated into C++ code behind it).
Emilio Garavaglia at 3-Jul-11 5:56am View
   
Deleted
Java is not for performance, C++ is not for "opennes", especially if used close to the hardware.
Gui can even be none of the two, but a HTML/XML browser app, driven by a C++ server socket.
 
I probably code the core as C++ module, with a plain C interface, to be linked by other modules, written in whatever language is suitable to make the job done.
 
A QT based C++ gui is fine (but .. hey .. that's not "pure C++", there is lot of other scripting translated into C++ code behind it).
Emilio Garavaglia at 2-Jul-11 15:13pm View
   
If you want to thank someone, post a comment to his own answer, don't post fake "answer" to yourself. The author you intend, may not notice it.
Emilio Garavaglia at 1-Jul-11 2:09am View
   
You should tell us what this code is supposed to do and what it does instead.
We cannot read your mind.
Emilio Garavaglia at 22-Jun-11 7:57am View
   
Yes, this was the initial thinking. But it fails in the assumptions: MACs aren't unique. There are simply not enough of them to track all the network adapters existed in the history. Manufacturer recycles them, assuming an "old released MAC" doesn't exist anymore. But this is something they cannot know for certain. hence the "high improbability", instead of "impossibility".
But a GUID also contains a timestamps. Even admitting the reuse of a MAC ... it will probably leave on a different timeframe.
Emilio Garavaglia at 13-Jun-11 5:46am View
   
Beware to the name "union": in C and C++ union is keyword (like "for", "void" etc.) and you shouldn't use it as a name for variables or functions.
 
Also, it seems you don't have a clean understanding of the concept of automatic variables and member variables, and even a not clean understanding on how array works across functions.
 
You have better not to afford this program, until the basic concept I mentioned are absolutely clean to you, or your further experience will end in tears!
 

Emilio Garavaglia at 9-Jun-11 2:25am View
   
Title changed.
Emilio Garavaglia at 4-Jun-11 16:26pm View
   
Don't post fake "solution"s. Add comments, if you want to reply to someone.
Emilio Garavaglia at 3-Jun-11 5:26am View
   
Of course: the only "compulsory" things are a value comparer, a conditional selector, and an iteration mechanism. Everything else is "Touring equivalent" and can be avoided. But we can substantially approximate "compulsory" with "extremely convenient" (and the evaluation is subjective). That's the only way I found to have this question to make sense.
Emilio Garavaglia at 2-Jun-11 16:59pm View
   
RTTI exist for valid reasons. It can be avoided if misused, but can be required exactly as virtual functions (see below)
Emilio Garavaglia at 31-May-11 8:41am View
   
"Do you think that they are not using any sort of hardware binding internally?" They bind a licence key with the hardware they run on. You can move the key as needed. A same MS windows DVD can be installed on many PC. But only one registration is "valid" (unless you unregister it). "go through the Windows 7 EULA ..." According to the Euoropean Council Court, EULAs are NOT SUPERIRO to laws. And the EEC law EXPLICITLY SAYS that to limit the end-user in using his own hardware (the user already payed for that) is illegal and that whatever the EULA say, it is invalid. It is a sentence of the European Court, valid across all the 24 member countries. No-one takes legal objection, since such EULAs had already been declared invalid, and there is no way for the EULA emitter to accuse anyone for that.
Emilio Garavaglia at 31-May-11 8:40am View
   
Deleted
"Do you think that they are not using any sort of hardware binding internally?" They bind a licence key with the hardware they run on. You can move the key as needed. A same MS windows DVD can be installed on many PC. But only one registration is "valid" (unless you unregister it).
 
"go through the Windows 7 EULA ..."
According to the Euoropean Council Court, EULAs are NOT SUPERIRO to laws. And the EEC law EXPLICITLY SAYS that to limit the end-user in using his own hardware (the user already payed for that) is illegal and that whatever the EULA say, it is invalid.
It is a sentence of the European Court, valid across all the 24 member countries. No-one takes legal objection, since such EULAs had already been declared invalid, and there is no way for the EULA emitter to accuse anyone for that.
Emilio Garavaglia at 31-May-11 2:44am View
   
Richard, the OP asked for an array of references, not a reference of an array (a reference is an alias, so a can THINK to an array of aliases ...)
A reference is a implicitly dereferenced const-pointer. It can technically stay into an array. The problem is that a reference must be initialized with a variable (an L-value) and there is no array initializer for that (array initializer require to be constant, thus references would be "implicily dereferenced const pointer to const" and not "implicitly dereference const pointer to vars" as required).
If I could do that, references will not anymore "not refer to anything".
We are, basically, saying the same thing.
Emilio Garavaglia at 30-May-11 9:06am View
   
A b_as_a = b actually is another A containing a copy of the A in B.
Wouldn't you mean A& b_as_a = b; ?!?
Emilio Garavaglia at 27-May-11 16:11pm View
   
not an answer

Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 1 Jan 1900
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid