Ajiq
Anybody here good in java?
Ajiq
I need help
Ajiq
In threading
Ilya
Anybody here good in java?
Someone is good in banning....
I_Interface
No channels, read books
Cherno prabably would be good.
Augmented
hello, is there a problem to use "struct" instead of "class" keyword, if i have only public definitions ? obviously struct acts like class, but it starts public by default, and can use private later, class starts private by default, but can be switched to public or protected... I know how it is working, But in general is there any possible issues, or is it a good practice to use "struct" instead of "class" for shortening the source code lines...
MilkBeforeCereal
only difference is the default visibility label in structures and classes
MilkBeforeCereal
you can use either
MilkBeforeCereal
structures by default is public, classes, private
Augmented
only difference is the default visibility label in structures and classes
so, it's not a problem to use both, when one is more suitable for specific case
MilkBeforeCereal
so, it's not a problem to use both, when one is more suitable for specific case
doesn't matter, but if you only have public stuff, might as well use structures for clarity
Augmented
structures by default is public, classes, private
yes, but i have only public definitons, i can use struct, to define class, i worried if there will be some incompatibilites when deriving child classses later
Augmented
thank you for that clarification
Augmented
i will assume these keyword are interchangeable, just default visibility differs, but doesn't affect compilers internal job
MilkBeforeCereal
Ilya
what else is different?
Default inheritance type
Augmented
If you are talking about class and structs YES
okay, but i was worried of inheritance incompatibilites, if it's only syntax and visibilitiy, it's great...
Augmented
i am trying to pack a library code, as much is possible, without violating standarts, and sacrifising readibility...
MilkBeforeCereal
Default inheritance type
still basically same 🤔 class derived is private, struct is public
Augmented
i am trying to get rid of cpp files when its possible, and to impelement functions inside the class definition section...
Augmented
i know it's worses the readability, but i use for just for simple functions, mostly single row...
Augmented
i am using this style only for the most basic and simple classes, like FIFO queues, linked list, memory pool etc.., member functions are single row, when i derive and extend that class i am using separate cpp file for function's code body, is it okay?
Augmented
another boring question
Augmented
does #pragma once, works like #ifndef header_h #define header_h ..... #endif it seems to do the job, but is this a good aproach?
Augmented
Yes it does
Great, and it saves 2 rows of source code
Anonymous
I don't think this is a good practice because not all compilers support #pragma once afaik
Vikram
Best book to learn C and C++ in easy way.. newbie like me
Augmented
Ok
I use few different compilers, but mostly GCC and G++, and it seem they support that, but is there any cavets from using it?
Vikram
What's this
Anonymous
#googleit
Stop it
Augmented
Okay, excuse me for asking dumb questions, i can google that of course, but i prefer information from humans, not machine...
MᏫᎻᎯᎷᎷᎬᎠ
Ok
The manual include guards can be little bit confusing Consider this example You have two folders each of which has user.hpp The first folder is Database contains the functionality that deal with Users table or database under the user.hpp file. The second folder has the definition of the class User under user.hpp You have two files with the same name under different folders(no confliction) When you generate both header files through IDEs Both of the files has the definition USER_HPP macro Then if both files were included (and will) It will cause one of them as it was not pre-processed that implys lots of hard to track compiler errors
MᏫᎻᎯᎷᎷᎬᎠ
Yeah
Anonymous
That's why they are usually prefixed with name of the lib
Anonymous
like BOOST_NOEXCEPT
Ilya
does #pragma once, works like #ifndef header_h #define header_h ..... #endif it seems to do the job, but is this a good aproach?
For "is it a good approach" - ONCE is not crossplatform, it is feature of a specific compiler
Anonymous
Good Luck :)
Hey, looks like I did it :)
Augmented
For "is it a good approach" - ONCE is not crossplatform, it is feature of a specific compiler
okay, so it's not standartized, but if it is supported, it can be used
Ilya
okay, so it's not standartized, but if it is supported, it can be used
There are problems with it, too. If two headers of same name are in two different directories, what the compiler should consider them to be? Same header or two different headers?
Ilya
okay, so it's not standartized, but if it is supported, it can be used
So I suggest for local small projects you can use ONCE, for crossplatform and production level projects -- use #ifdef GUARDs and, maybe ONCE, if #pragma once gives you better compilation speed
Augmented
There are problems with it, too. If two headers of same name are in two different directories, what the compiler should consider them to be? Same header or two different headers?
i see, it depends how compiler remembers that file, when it reached #pragma once while parsing... if it stores it's full pathname and check for it later, or it is emulating #ifndef/#define directives, with only with the short file name...
Ilya
Besides, #pragma once don't have explicit end , so it can only switch off the entire source file
Augmented
So I suggest for local small projects you can use ONCE, for crossplatform and production level projects -- use #ifdef GUARDs and, maybe ONCE, if #pragma once gives you better compilation speed
yes, i use #pramga once, only for small projects and in header only libraries, i will use full guarding when it's a complex project with a lot of including and nested library dependencies
Anonymous
https://pastebin.com/afTfim57 Can`t figure out! error: array type 'char [46]' is not assignable. More details about error in the end of the code. Can someone help me? I find that I can solve this problem using function strcpy but how can I do this correct?
Anonymous
#include <stdio.h> void printer (int *p,int *q) { int x=*p+6; int y =*q-30; printf(“%d\n”,x); printf(“%d\n”,y); } void subprint(int *x,int *y) { *x=*y/7; *y=*y*3; printf(“%d\n”,x); printer(&*x,&*y); printf(“%d\n”,*x+1); printf(“%d\n”,*y-2); } void print(){ int x =42; int y=x/11; subprint(&y,&x); printf(“%d\n”,y); printf(“%d\n”,x); } int main () { int x =17; int y=84; print(); return (0); }
Anonymous
I cnt get output ..
バレンタインがいない柴(食用不可)
Hi, I've been a developer from the JAva background and have been picking up C++ since last year. I think for the basic C++ (pointers, OOP, ..etc) I'm able to master that well, but feel I need to polish up my skill on the newest C++ releases (e.g. C++ 17) because i've had difficulty employing the best practice. Are you able to suggest me a good book to continue with my learning? Thanks!
Anonymous
It's called "effective modern C++" by Meyers
Anonymous
It's a good one, but it's C++14 only
バレンタインがいない柴(食用不可)
oh wow i'm also googling this book at the same time!
バレンタインがいない柴(食用不可)
It's a good one, but it's C++14 only
ya.. i can see that too. i hope it doesn't hurt too too much :(
バレンタインがいない柴(食用不可)
@unterumarmung thanks man ;)
Anonymous
ya.. i can see that too. i hope it doesn't hurt too too much :(
I don't think so It gives you an idea of how modern C++ works And modern C++ is based on C++11
Anonymous
I suggest you to watch CppCons as well, it will boost your knowledge
Augmented
hi again friends, another silly question from me: if "," is used instead of ";" to separate operations (not when defining variables), is the execution order preserved e.g. crc >>= 4, crc ^= Table[idx], crc += 1234; Will this execute as ";" was used to separate the three operations? I like to use "," to keep the expression on single row after code refactoring and "beautification"... it looks more atomic, when there are few operations to the same variable, instead of writing as single expression like: crc = ((crc>>4)^table[idx]) + 1234; What you think about that?
Anonymous
https://pastebin.com/MBKQTrt1
Anonymous
https://pastebin.com/v34djD8f