- primary expression - 7 Updates
- Einsteigerfreundliche GUI - 5 Updates
- Overloading copy constructor - 2 Updates
- creating a binary tree - 1 Update
- the new {} syntax - 1 Update
- Why cast to void* in this function? - 4 Updates
- hidden static - 2 Updates
ruben safir <ruben@mrbrklyn.com>: Nov 21 03:54PM -0500 On 11/21/2016 08:17 AM, Chris Vine wrote: > unnecessarily confused by the basics - in this case between a type and > a pointer to the type. You may also be confused by the syntactic > difference between a pointer and a reference. I am relearning C++ after a 6 year lay off. And BTW, the compiler is probably the best instructor for C and C++ |
ruben safir <ruben@mrbrklyn.com>: Nov 21 03:56PM -0500 On 11/21/2016 08:17 AM, Chris Vine wrote: > ng to the parent class in his post "the new {} syntax", your > problem is that you are trying to initialize a parent* object 'tmp2' > with something other than an address of a parent object. right. I thought that is the syntax, but I misunderstood. Thank you, Ruben |
"Öö Tiib" <ootiib@hot.ee>: Nov 21 02:07PM -0800 On Monday, 21 November 2016 22:54:49 UTC+2, ruben safir wrote: > > difference between a pointer and a reference. > I am relearning C++ after a 6 year lay off. And BTW, the compiler is > probably the best instructor for C and C++ Compiler is definitely worst instructor of those two languages whose *every* feature contains a number of related undefined behaviors that tools are not obliged to diagnose. You can not find out about undefined behavior using compiler. Undefined behavior sometimes results with a program that sometimes appears to work or even that most of the time appears to work. So the result of your voodoo programming is often somewhat unstable program that acts in somewhat insane manner and your own poisoned brains with misinformation about what voodoo spells work in C++. |
Louis Krupp <lkrupp@nospam.pssw.com.invalid>: Nov 21 03:18PM -0700 On Mon, 21 Nov 2016 15:54:40 -0500, ruben safir <ruben@mrbrklyn.com> wrote: <snip> >I am relearning C++ after a 6 year lay off. And BTW, the compiler is >probably the best instructor for C and C++ The compiler might have better social skills than some of us on this newsgroup, but I wouldn't call it a good instructor. It's kind of terse. I have a copy of Stephen Prata's C++ Primer Plus, Sixth Edition, 2012, and it covers at least some of what's changed in C++11. Amazon lists other titles. Read the reviews, buy whatever looks good from Amazon or locally, and happy reading. Louis |
JiiPee <no@notvalid.com>: Nov 21 10:29PM On 21/11/2016 22:18, Louis Krupp wrote: > The compiler might have better social skills than some of us on this > newsgroup Yes, at least it is always 100% truthfull :). It does not tell lies... |
JiiPee <no@notvalid.com>: Nov 21 10:29PM On 21/11/2016 22:18, Louis Krupp wrote: > I have a copy of Stephen Prata's C++ Primer Plus, that was my first C++ book back in 1996 I bought, to learn C++. It was good then... I liked it. I learned well using it. i tried also others but this was best for me. |
"Christopher J. Pisz" <cpisz@austin.rr.com>: Nov 21 05:12PM -0600 On 11/21/2016 4:29 PM, JiiPee wrote: >> The compiler might have better social skills than some of us on this >> newsgroup > Yes, at least it is always 100% truthfull :). It does not tell lies... I learned C++ from this newsgroup, Victor, Alf, and Oo Tiib. |
Christian Steins <cs01@quantentunnel.de>: Nov 21 06:08PM +0100 Am 20.11.2016 um 18:01 schrieb Öö Tiib: > Linux, iOS and Android. Also there are more people who use it and > so more job offers where Qt framework is used than where wxWidgets is > used. Sorry for the german OP, clicked on wrong group. Anyway thanks for your answer. So, QT seems to be preferred over wx by most c++ people. Christian |
"Öö Tiib" <ootiib@hot.ee>: Nov 21 11:15AM -0800 On Monday, 21 November 2016 19:09:01 UTC+2, Christian Steins wrote: > Sorry for the german OP, clicked on wrong group. > Anyway thanks for your answer. So, QT seems to be preferred over wx by > most c++ people. It is unclear what most C++ people prefer. Lot of C++ people write embedded software that is in devices without graphics output or server-side services that have some network interface or command-line tools with text I/O or games that use graphics rendering libraries built upon OpenGL or Direct3D. I just say that Qt seems more useful for me and more popular than wxWidgets among C++ programmers whom I know. Also for example on programmers Q/A site like Stack Overflow it seems to be more popular. See: http://stackoverflow.com/questions/tagged/wxwidgets gives 3K questions http://stackoverflow.com/questions/tagged/qt gives 54K questions However for example unity3d framework gives also lot of questions ... http://stackoverflow.com/questions/tagged/unity3d gives 21K questions ... so who knows what most prefer. |
David Brown <david.brown@hesbynett.no>: Nov 21 08:36PM +0100 On 21/11/16 20:15, Öö Tiib wrote: > However for example unity3d framework gives also lot of questions ... > http://stackoverflow.com/questions/tagged/unity3d gives 21K questions > ... so who knows what most prefer. It is always difficult to know what these sorts of statistics mean, or if they mean anything at all. It could be that QT is 18 times as popular as wx - but it could also mean that it is 18 times as hard to use, or that the wx documentation is 18 times as clear as QT's, or that the wx project forums are 18 times as good as the QT project forums so that people don't have to ask on Stack Overflow. I think both are popular toolkits, with their pros and cons - I certainly would not choose between them based solely on this information. I also would not dismiss other possible toolkits either. My advice to the OP is to read a bit on the project webpages, especially the tutorials. Check that the licensing suits your project, and try out a "hello world" with each toolkit that looks interesting. Then ask questions in newsgroups that are a bit more specific once you know what to ask about. |
Melzzzzz <mel@zzzzz.com>: Nov 21 08:50PM +0100 On Mon, 21 Nov 2016 20:36:23 +0100 > use, or that the wx documentation is 18 times as clear as QT's, or > that the wx project forums are 18 times as good as the QT project > forums so that people don't have to ask on Stack Overflow. Qt has excellent documentation and examples. Heck has IDE as well. Really easy peazy to quickly get results. -- press any key to continue or any other to quit |
"Öö Tiib" <ootiib@hot.ee>: Nov 21 01:44PM -0800 On Monday, 21 November 2016 21:36:36 UTC+2, David Brown wrote: > > ... so who knows what most prefer. > It is always difficult to know what these sorts of statistics mean, or > if they mean anything at all. It could be that QT is 18 times as Good questions are rare on SO, so these are novices who ask there. Count of ignorant people in trouble has always been quite good indicator of desire to use and therefore popularity. > popular as wx - but it could also mean that it is 18 times as hard to > use, or that the wx documentation is 18 times as clear as QT's, or that C++ is not really made easy to use for novice. Novice is likely struggling and most often with C++ itself, its syntax, tools and simple logic errors. The framework or library just happen to be the frame of reference for that story of "torment" and "agony" of gaining skills with C++. ;D > the wx project forums are 18 times as good as the QT project forums so > that people don't have to ask on Stack Overflow. Both have really good documentation and decent forums IMHO so there can't be such differences. > a "hello world" with each toolkit that looks interesting. Then ask > questions in newsgroups that are a bit more specific once you know what > to ask about. Yes. One's own eye is the king. http://doc.qt.io/qt-5/qtexamples.html http://docs.wxwidgets.org/3.1/page_samples.html |
bitrex <bitrex@de.lete.earthlink.net>: Nov 21 03:37PM -0500 How can I do something like this with a copy constructor where I'd like a second default argument, where the default is a member variable of the class the copy is being made from MyClass(const MyClass& my_class, member=my_class._member) : _member(member) { etc... Currently I'm getting a "local variable 'my_class' may not appear in this context" error as it isn't in the appropriate scope for a default argument. |
Marcel Mueller <news.5.maazl@spamgourmet.org>: Nov 21 10:06PM +0100 On 21.11.16 21.37, bitrex wrote: > Currently I'm getting a "local variable 'my_class' may not appear in > this context" error as it isn't in the appropriate scope for a default > argument. You need to overload the constructor. MyClass(const MyClass& my_class) : _member(my_class._member) ... MyClass(const MyClass& my_class, member) : _member(member) ... Default members are no overloads. They are just default arguments that are passed by the caller when no argument is given. This might look similar to overloading but it is entirely different. If you change a default parameter you need to recompile every caller. If you change the overloaded implementation (without the additional parameter) to assign another default value you need to recompile the callee only. Marcel |
ruben safir <ruben@mrbrklyn.com>: Nov 21 03:58PM -0500 CXX:=g++ CXXFLAGS:=-Wall -ggdb -pg -pthread LDFLAGS:=-L/usr/local/lib/mysql -lmysqlpp -lmysqlclient maxpath : maxpath.o main.o ${CXX} ${CXXFLAGS} -o maxpath maxpath.o main.o main.o : main.cpp ${CXX} ${CXXFLAGS} -o main.o -c main.cpp maxpath.o : maxpath.cpp maxpath.h ${CXX} ${CXXFLAGS} -c maxpath.cpp clean : rm maxpath *.o make.deps touch *.cpp *.h include make.deps make.deps: *.cpp ; gcc -M *.cpp >$@ |
ruben safir <ruben@mrbrklyn.com>: Nov 21 03:50PM -0500 On 11/21/2016 08:59 AM, Alf P. Steinbach wrote: > You were introducing needless and misleading uncertainty. Alf, your no gem either. Reconsider what your saying because your way off and if you were one of my children at the table, would be sent upstairs to mull over things. Reuvain |
"Ahmet Can ÜN" <ahmetcanun@gmail.com>: Nov 21 10:54AM -0800 Hi, This function rests in fbstring.h header from facebook folly library. Link: https://github.com/facebook/folly/blob/master/folly/FBString.h#L434 I didn't see why this code casts p back and forth to void*? static RefCounted * fromData(Char * p) { return static_cast<RefCounted*>( static_cast<void*>( static_cast<unsigned char*>(static_cast<void*>(p)) - sizeof(refCount_))); } Why can't it be written like this? Can anyone see a logical reason? static RefCounted * fromData(Char * p) { return static_cast<RefCounted*>( static_cast<unsigned char*>(p) - sizeof(refCount_)); } |
Gareth Owen <gwowen@gmail.com>: Nov 21 07:19PM > static_cast<unsigned char*>(p) > - sizeof(refCount_)); > } What did your compiler say? Clue: Any pointer type can be static_cast to a void*, and a void* can be static_cast to any pointer type, but ... |
"Ahmet Can ÜN" <ahmetcanun@gmail.com>: Nov 21 11:51AM -0800 On Monday, November 21, 2016 at 10:20:01 PM UTC+3, gwowen wrote: > What did your compiler say? > Clue: Any pointer type can be static_cast to a void*, > and a void* can be static_cast to any pointer type, but ... Thank you. I'm still under the influence of C. |
"Öö Tiib" <ootiib@hot.ee>: Nov 21 11:54AM -0800 On Monday, 21 November 2016 20:54:36 UTC+2, Ahmet Can ÜN wrote: > static_cast<unsigned char*>(p) > - sizeof(refCount_)); > } Because static_cast is not meant for type punning between unrelated types like that. It is legal to use reinterpret_cast like that: return reinterpret_cast<RefCounted*>( reinterpret_cast<unsigned char*>(p) - sizeof(refCount_)); It is legal to use C style cast like that: return (RefCounted*)( (unsigned char*)(p) - sizeof(refCount_)); |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Nov 21 05:31PM On Mon, 21 Nov 2016 14:48:15 +0000 > ODR-using it. Casting it to lvalue of another type is another. I > don't at the moment have the C++ standard in front of me to give you > the reference. I do now. It's §9.4.2/3. "If a non-volatile const static data member is of integral or enumeration type, its declaration in the class definition can specify a brace-or-equal-initializer in which every initializer-clause that is an assignment-expression is a constant expression (5.20). ... . The member shall still be defined in a namespace scope if it is odr-used (3.2) in the program and the namespace scope definition shall not contain an initializer." This implies that the initialised const static integral member need not be defined in namespace scope (its declaration is sufficient) if it is not ODR-used. Chris |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Nov 21 06:18PM On Mon, 21 Nov 2016 17:31:03 +0000 > Chris Vine <chris@cvine--nospam--.freeserve.co.uk> wrote: > > On Mon, 21 Nov 2016 13:26:07 GMT > > scott@slp53.sl.home (Scott Lurndal) wrote: [snip] > implies that the initialised const static integral member need not be > defined in namespace scope (its declaration is sufficient) if it is > not ODR-used. However I do now recall having experiences similar to the one you mention. Some forms of ODR-use, such as assigning to a const reference, may be optimized out with a sufficiently high level of optimization, and will compile and link even though technically the code in question is not conformant. That may be what you had in mind. But where the static member is not ODR-used, you should be safe from that problem. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment