Sohit
Anyone have a python discussion group on telegram??????? If yes then pls let me know..
Indolent
int* ptr; ptr[0] = 13; // What's happening in line 2?
Indolent
struct node { int a; int b;
Indolent
Now like if I want to make an object of this struct with the new keyword how do I do it? Like it throws an error "conversion to non scalar"
Indolent
node p1 = new node; // This throws error. Why?
Indolent
Yeah exactly why that pointer thing works? Not not a normal datatype?
Indolent
You can do this Olli.
olli
what can I do?
olli
Yeah exactly why that pointer thing works? Not not a normal datatype?
because "the result of the new-expression is a pointer to the object created."
Indolent
Why *pNode works and not p1?
Indolent
#include <iostream> using namespace std; struct Node { int d3 = 13; }; int main() { Node* p1 = new Node; *p1->d3; return 0; } // This throws an error. How do you print the value of d3? Using p1 object?
Indolent
I am here to avoid that page.
olli
What would be the valid syntax then?
the page I linked has an example
Indolent
the page I linked has an example
Hmmm. Looks promising.
Anonymous
#include <iostream> using namespace std; struct Node{ int d3 = 13; } p1; int main(){ Node *p1 = new Node(); p1->d3; return 0; }
Anonymous
Sorry, nothing (), it function
Indolent
Okay
Anonymous
Okay
So, i would to know that you final solution
Anonymous
i follow
Anonymous
☺️
Indolent
👍👍
Anonymous
👍👍
Why don't you use class? For example:
Anonymous
Okay
class Node{ public: const int d3 = 13; };
Indolent
Why don't you use class? For example:
Actually I am learning to implement a linked list. In the tutorial they use both class and struct. So therefore I'll have to learn both.
Indolent
Ok. Thanks
No problem dude. You're a legend.
Indolent
👌👌👌
Ибраги́м
http://0x80.pl/
Indolent
struct Node {}; int main() { Node *p1; Node *p2 = new *p2; } // What is the difference between *p1 and *p2? (They are different because while creating *p1 the constructor doesn't gets called. I have tried it.) So what's happening?
Meet
*some
Meet
And difference between (1) Node *p2; And (2) Node *p2 = new Node; Is in 1st it is pointer to node you can not store any new value in it. So by this you can point existing node In 2nd case there new memory will be allocated for value you want to store.
MᏫᎻᎯᎷᎷᎬᎠ
https://www.fluentcpp.com/2019/02/07/why-you-should-use-stdfor_each-over-range-based-for-loops/
Meet
👍
Alex
regexp in my code(boost library): (?:([^\n]{2, 200}[^.\n]))?(\\A|\n)\\s*(?:Student['`]s Name|Name)(?:[ \t]*:)?\\s*\n\\s*(\ ?:Institution Affiliation|Institutional Affiliation|Institution['`]s Name|Institution of learning|Institution of affiliation|\ University|Institution)(?:[ \t]*:)?\\s*\n The complexity of matching the regular expression exceeded predefined bounds. Try refactoring the regular expression to m\ ake each choice made by the state machine unambiguous. This exception is thrown to prevent "eternal" matches that take an in\ definite period time to locate. this part is the problem: (?:([^\n]{2, 200}[^.\n]))? any ideas to fix?
数学の恋人
What's the best way to throw exception (I don't have to catch it)
数学の恋人
as of now I'm doing like #include <exception> class mainClass { public: class someException : public exception {} void someMethod(void) { // Do something throw someException; } };
数学の恋人
What's the best way to throw exception (I don't have to catch it)
best is kinda vague and broad term here, What I really mean is what is good practice to throw exception
Anonymous
fseek(fp, 0, SEEK_END); if(feof(fp)) printf("END"); Why doesn't feof return true? It does if I read a character using getc(fp) before the if condition. fp is a pointer to a file opened in read mode.
数学の恋人
Веселый Роджер
Can anyone explain how a pointer to function works and why would i need it?
Alex
to pass function as argument for example
Веселый Роджер
to pass function as argument for example
aah, so instead of passing the return of a function, i can pass the function itself and call it within another function?
MᏫᎻᎯᎷᎷᎬᎠ
why the standard library doesn't has such a construct: to make the compiler decide whether to pass by value or reference instead of just passing by const T& because we don't know what the user will pass template<typename, bool> struct OptimizedType; template<typename T> struct OptimizedType<T, true> { using type = const T&; }; template<typename T> struct OptimizedType<T, false> { using type = T; }; template<typename T> using OptTypeT = typename OptimizedType<T, (sizeof(T) > 8)>::type; then the user will just define his function like this template<typename T> void test(OptTypeT<T> value){}
Alex
aah, so instead of passing the return of a function, i can pass the function itself and call it within another function?
for example you have traverse function, and for each node needs to call a function. so you pass pointer to specific function as argument. for example you have some event and need to call some a function, so you pass pointer to specific function as argument in event handling engine
pappupanchi
i still cant find a solution for this
pappupanchi
i want to use vs code i have been using atom
pappupanchi
can anybody help me about thus issue
Dima
i still cant find a solution for this
0) don’t use mingw 1) it requires WinMain instead of main()
pappupanchi
what shall i use then
数学の恋人
to pass function as argument for example
wouldn't functors come in useful there?
数学の恋人
what shall i use then
wsl with gcc is also good, else install toolchain using visual studio community
pappupanchi
ok
数学の恋人
ok
best would be remove winblows, install GNU/Linux, I'd say fedora or openSUSE, install gcc, build-essentials, etc. vscode and get started
数学の恋人
I'm just saying, you don't have to do that
Artöm
It can be solved by making a simple inline wrapper i saw in SO, but I cant find it
Artöm
Artöm
i still cant find a solution for this
Use visual studio if possible. Wsl is also a good option
pappupanchi
I found the solution tho
pappupanchi
Just pressing the run button doesn't work
pappupanchi
I have to debug it then exe file
pappupanchi
Gets created
pappupanchi
And then it run
pappupanchi
Dont know why it happens but it is as it is