« first day (830 days earlier)      last day (2014 days later) » 

1:21 AM
Yo I got an odd question I think... as I've been smashing code for 2 years and I still don't know wtf it means soo... what do I do with this example? on win ?
mkdir build
cd build
cmake ..
cmake --build . --config Release --target check
 
 
5 hours later…
6:04 AM
Can an interface inherit another interface? Say I have InterfaceA and InterfaceB, I want InterfaceA <- InterfaceB <- ClassA where somebody can have a reference to InterfaceB and still use functions from InterfaceA.
So can InterfaceB 'pass on' the function from InterfaceA?
 
yes, and in C++ you can even implement multiple interfaces
 
@Mikhail Do I need to do something in InterfaceB to say that I'm not implementing InterfaceA functions here, I'm 'passing' them on?
Perhaps declare them virtual again?
 
the virtual-ness is inherited (virutal = 0, stuff), aka the place holders are inherited
 
@Mikhail What if it's pure?
 
Pure virtual? Yes, the place holder is passed down.
Also OOP is evil and you shouldn't do it unless your goal is to simulate something
 
6:13 AM
I'm making GUIs
 
Use Qt, but yes, GUIs might be a good use of OOP
 
can't, got to roll my own
 
Don't believe you
 
trust me
 
 
2 hours later…
8:32 AM
Hey.
I have a example that uses cmake and something like
add_subdirectory(lib)
lib_add_module(cmake_something src/main.cpp)
But the library is not in my project. What is the equivalent other commands that I can link external folder to my project and do the same thing? I'm lost :- (
 
 
5 hours later…
1:14 PM
hello
i tried to use the if (condition) ? x : y which i am not very well familiar with and i got error. could you tell me what i did wrong so i could fix it? what i did is: if (node!=nullptr) ? return true : return false;
 
x and y must be expressions. return whatever; is a statement
also, utterly pointless in the first place
return node != nullptr;
there
 
nwp
There are 2 versions. Version 1: if (condition) {truebranch;} else {falsebranch;}. Version 2: condition ? trueexpression : falseexpression. You are mixing the versions together in a way that they don't fit.
 
so if i combine both answers, i can't use return with the 2nd version?
 
1 min ago, by milleniumbug
x and y must be expressions. return whatever; is a statement
statements are not expressions
 
nwp
You can. return node != nullptr ? node->next : nullptr; is somewhat common.
 
1:25 PM
https://onlinegdb.com/SysmjIDs7 , can i overcome the following error using 'this' instead of the tree object i instantiated in main? functionality.cpp:102:20: error: ‘tree’ was not declared in this scope
TNode* node = tree->search(id1);
 
1:47 PM
can i write TBST obj to resolve it?
in the function parameters i mean
 
nwp
2:06 PM
There are so many errors in that code that the compiler simply tells you. The first error I see is in functionality.cpp:23:5 because you have a catch without a try.
 
i'm fixing it. instead of a try catch block like i did earlier(before i tried to use individual functions to make it more clear), i'm using a constant in the header and just verifying if given id is not larger than the const
id > MAXID ? std::cerr<< "Given id is too large" << std::endl; : return; is this a correct way to write the inline if?
 
57 mins ago, by milleniumbug
x and y must be expressions. return whatever; is a statement
 
nwp
Just use if and else.
 
lol, okay
 
std::cerr<< "Given id is too large" << std::endl; almost fits, but you have to remove a semicolon in order to make it an expression
that said, just use if/else here
 
2:16 PM
in the case of inline if, can i omit the else part? (after the : )
 
nwp
No. Also it's not an "inline if".
 
it's an conditional operator
 
then how should've i written it so it would be correct, if i don't have an else?
 
nwp
The difference is that if/else is a statement. It has no return value. ?: is an expression which has a value. Since both cases must return the same-ish type of value you cannot leave out a case.
 
You can't write this using the conditional operator
 
nwp
2:18 PM
You can't. You can kinda fake it by putting some useless value there to make it compile.
 
that's what i tried to do with return lol
 
nwp
But that is not what you want. You are not even using the return value. No point in even using ?: when you don't use the primary feature.
 
sorry for the massive amount of questions, but in addition to making the program work, i'm also trying to learn as much as i can
 
the point of conditional operator is to be able to write stuff like int a = x >= 0 ? x : 0;
 
so it might sound quite noobish, but i guess that i don't learn as fast as others. it took me about two months to write it and learn cpp from scratch
now i understand, thank you millenium
 
2:22 PM
in general, if you don't use the evaluated expression in any way, you don't want conditional operator. You also don't want to put complicated expressions there. Nor side effects.
 
2:32 PM
how can i fix this: if(std::is_integral<int>(!id)) {std::cerr << "Given input is not an integer" << std::endl;} ?
 
this code makes no sense
 
i am trying to check whether a given id is an int
so instead of the regualr floor division to check, i want to use std::is_integral, but i don't know how to use it correctly
every example i found includes templates
can it be used for a simple checking?
 
id is declared as int. It's obviously an integral value at this point
 
nwp
@BeginningMath That's because it exists to check if a given type is an integer type which is only useful in templates. It does not parse input.
 
actually you are right. but assuming a had a string, how could i check if given string is an integer? using a try catch and std::stoi and catching an error or something like this?
 
nwp
2:35 PM
The way to check if input is an integer is int value; if (std::cin >> value) { //use value } else { //error, failed to read an int }.
 
if it's in a string, then yes, you catch an exception thrown from std::stoi
if you read from stream like ^^, then you want the way presented above
 
3:06 PM
thanks
can you please help me with: functionality.cpp: In function ‘bool checkIfExistsPredecessor(int)’:
functionality.cpp:55:20: error: ‘tree’ was not declared in this scope
TNode* node = tree->tree_predecessor(tree->search(id)); ?
the scope problem is a huge issue for me and would like to learn how to deal with it properly
 
nwp
Where is the tree that you meant to reference?
 
sorry, it was the most stupid situation ever lol
added a proper call and fixing the broken links
functionality.cpp: In function ‘void printPredecessor(int)’:
functionality.cpp:67:26: error: ‘args’ was not declared in this scope
int id1 = std::stoi(args[1]); this one i really don't know how to fix
what would be the right syntax?
it's not void printPredecessor(int, args) i believe
std::vector<std::string> args is this the correct way?
 
3:45 PM
I don't know how to fix: functionality.cpp: In function ‘void printPredecessor(int, std::vector<std::basic_string<char> >, TBST*)’:
functionality.cpp:56:6: error: ‘ThreadedNode’ was not declared in this scope
ThreadedNode* node = tree->tree_predecessor(tree->search(id));

this is a much bigger problem and would appreciate help with it
i can't pass to the function TNode, TBST should be the only object that deals with it
anyway to fix it?
 
3:58 PM
basically this is the only error that prevents it from compiling. can anybody help me fix it?
 
4:17 PM
@nwp, could you please help me solve this problem? i'm stuck here
 
 
2 hours later…
nwp
6:27 PM
@BeginningMath You are trying to use a type ThreadedNode which was not defined anywhere. Same error as before.
 
 
2 hours later…
7:57 PM
thanks. those were indeed basic mistakes
else{std::cerr<< "Successor does not exist" std::endl; }
i don't understand what's wrong with this
sorry
functionality.cpp:72:60: error: statement cannot resolve address of overloaded function
else{std::cerr<< "Successor does not exist"; std::endl; }
what should i do to correct it?
 
std::cerr<< "Successor does not exist" std::endl; is missing a << between the string literal and std::endl
that said, don't use std::endl
just write std::cerr << "Successor does not exist\n";
 
right, another noobie mistake lol
can you explain to me why please?
 
see the video above
it explains pretty well, and it's short (3 minutes 12 seconds)
 
thanks, i'll watch it soon. those were my last 2 compiler errors, so after it will compile i'll have to do some enhancements
 
8:15 PM
yayyyyyyyyyyyyy it compiles!!!!!!
i'll soon change the std::endl, can you take a look and give me any other suggestions? regarding the menu i want to present a better one, that's why its marked with comment
if anyone has any suggestions, please tell me how to improve it
 
8:39 PM
Anyone on? I need help with overloading this output function, but everytime it sends the cpu into hell. I need help.....
 
9:29 PM
Ok never mind, seems to be a glitch caused by a while loop
 
@NiNisanNijackle For future reference, just ask. nohello.com
 
Crap forgot about that rule. Sorry about that....
 
Not a rule
Not a problem. It just means that you're less likely to be helped if you don't actually ask the question
 
Yea, I need to work on the soft skills....
Hey what kind of spacing format would I try doing to get something centered in a console? I have been trying to get the thing to do a number of spaces based on the index but it ins't doing desired results
Here is what the console is printing and what I want. pastebin.com/H1zBhnmq
 
9:47 PM
Try breaking that into two steps: separating the *s with spaces, and indenting each line to the correct amount
What I mean by that is: implement one first before the other
 
Is it ok if I think out loud? I normally solve it if I just try to explain it to someone.
 
Go ahead
 
Ok, so I noticed I did 3 spaces for the first value. The last value is 4, so the spaces for the first one should be the last value -1
actually its the value of the last value of spaces
 
10:02 PM
Ok got it, all I simply had to do is add a space...... lol
 
Nice
 
10:15 PM
can somebody look at my code and give me any additional suggestions?
 
10:26 PM
What are you tring to do @BeginningMath
 
it's an implementations of a threaded binary tree
the menu is marked as a comment because i'll write something better later
or gui it, dunno
 
oh, I haven't really played around with binary trees, but I do know an overview of it. I might be able to help.
Is it the typical /\ binary structure or something else?
 
similar to a binary search tree, but with threads
 
Couldn't you just do a switch statement of bools to clean the code up more?
 
could you elaborate please? it's interesting
 
10:34 PM
I normally like trying to do a switch statement if possible to keep the code cleaner and easier to handle. If there is a bunch of it statements.
I'll share an example. Give me a second
 
you're right. i think i can improve tbst.cpp more
 
There are like 20 statements in there and it would be even more if I don't do 2 + booleans in each if statement
 
case X ... Y: is a compiler extension
 
Yea it depends on the compiler, but the point is that it's normally nicer on the eyes if there are a bunch of statements comparing to one thing.
 
i'll try to look on how to implement it nissan, thanks
 
10:38 PM
(which is fine if you're fine with compiling under the compiler you're currently using, but not if you want standard compliance)
 
millenium, could you give me any ideas to make my code better? (still need to change endl to
new line
bah, pressed on enter
 
@milleniumbug The point is that switch statements are easier on the eyes if possible. I know the ... is depends on the compiler, but it's supposed to be an example of a situation I would use a switch instead. Not anything for his specific problem
@BeginningMath I'll try to see if I can switch statement your thing, or just clean it in general.
 
thank you very much
 
11:06 PM
Are you still on?
ok, then... Peace!!! :)
 
11:46 PM
thanks. good night, tried to watch videos from the cppcon
 

« first day (830 days earlier)      last day (2014 days later) »