« first day (1193 days earlier)      last day (1643 days later) » 

4:26 AM
@nwp What shouldn't I write?
 
5:01 AM
What is a better approach
MainDir->
            | Include->
            |              |->Module1 ->
            |src->
            |              | ->Module1 ->

Or
MainDir
            |->Include
            |->Src
            |Module1->
            |                |Include
            |                |Src
For a project that is built up from smaller modules
 
 
4 hours later…
9:02 AM
Does it really cost a lot to include a big header file?
with compilation?
Is it a good idea to copy some struct and macro from the official header file to my own header file?
 
9:28 AM
@DexterLiu not a lot but it does add up
it's a good idea to minimize the amount of translation unit that need to include the big header files
 
9:53 AM
Could you shortly explain, what do you mean by translation unit ?
 
 
2 hours later…
11:44 AM
@DexterLiu a translation unit is a cpp file with all of its includes included. It's the thing a compiler actually compiles. In the traditional build system each cpp file is in its own translation unit.
 
12:33 PM
OK. That is good info, thanks!
 
 
3 hours later…
3:51 PM
I watched Herb Sutter's cpp con videos, I really like it!
cpp con 2016
 
 
1 hour later…
nwp
5:21 PM
@Rick The code in the message I linked my message to.
Specifically adding extern "C" to the header and not to the implementation.
 
5:51 PM
Which trick will help me here? Let assume this code:

?? *var;
if (IsDog())
var = new Dog(); // Dog class ctor.
else
var = new Cat(); // Cat class ctor.

Here I want to set the `var` type in runtime. Both Dog and Cat class has same public method prototypes (same return types and same parameters).
 
@Biswapriyo That's pretty much the situation that led people to invent inheritance.
 
@Biswapriyo you'll need to create a pure virtual base class
e.g. an interface
 
I forget how to type code here
 
class Pet {
    public:
        virtual void do_something() = 0;
};
class Dog : public Pet { /* implement do_something */ };
class Cat : public Pet { /* implement do_something */ };

Pet *var = isDog() ? new Dog() : new Cat();
var->do_something();
 
@DexterLiu just <kdb>shift</kbd> + <kbd>enter</kbd>
and apparently that doesn't work
lol
@JerryCoffin /sigh raw new?
 
5:57 PM
@Mgetz Only because that's what he started with (one battle at a time).
 
fair, which gives us the intro into "don't use raw new and delete"
 
Go for it.
 
@Mgetz what should I use?
 
@Biswapriyo std::unique_ptr and std::make_unique usually
XD
:47605263 The great mindless think alike
 
@Mgetz Mindless I can believe. Great is open to more question.
 
Thank you :)
 
So bad that Pet *var = isDog() ? new Dog() : new Cat(); this line does not work
I think it is quite good XD
@Mgetz what is <kdb> ?
 
pastebin.com/gmHjnf4V , i am solving follwing problem ,i am trying to precompute the path for each input
but bfs is causing infinite loop
can anybody look into this
?
 
6:14 PM
Looking for a C++ programmer to chat on Skype about random topics. Anyone?
 
// maybe create a zoom room
@sunil you are doing q.pop() and then q.push() ?
 
@DexterLiu // What's that?
 
something like skpye
but you do not need to have an account
 
@DexterLiu Oops--yeah. You'd need to add some ugly casts to make it work.
 
@JerryCoffin Honestly, I think it is really good XD
 
6:24 PM
@DexterLiu The platform isn't important. Just need a C++ enthusiastic who is willing to have a chat.
 
@De
@DexterLiu wait
i am looking
 
@Milad If you want to chat about actual C++, just do it here. If you want to chat about other topics, The Lounge will probably work.
 
@DexterLiu can you excplain more
Please
 
I did not see all of your code
 
it is whole code
 
6:26 PM
only because you have endless loop and your while is like : while (!q.empty())
so your q is not empty
 
@JerryCoffin Yup! Thanks!
 
undersrtand ,but bfs eventually make it empty
but it is not heppning
 
well, if it will be empty, it will get out..
<kbd>Ctrl</kbd>
@Mgetz this does not work
 
I thought I said that
why do you keep trying?
also please keep pings to a minimum
 
because I wanna know how it works
 
6:35 PM
it doesn't in the chat apparently?
 
xD yeah
 
@DexterLiu I would start with some data that forms a simple tree, and do a bfs on that.
class node {
  int val;
  node *left;
  node *right;

  node(int val, node *left = nullptr, node *right = nullptr)
    :val(val)
    , left(left)
    , right(right)
  { }
};

node leaf1(1);
node leaf2(2);
node leaf3(3);
node leaf4(4);

node intermediate1(10, leaf1, leaf2);
node intermediate2(11, leaf3, leaf4);
node root(20, intermediate1, intermediate2);

// now do a bfs starting from root
 
why bfs a tree?
and why @me ?
I am confused
xD
 
it is not a tree
bfs is traversal
 
@DexterLiu Because it's a decent starting point toward understanding how things work. The next step is that when you traverse something that might have cycles, you mark nodes as you visit them, so you don't go in circles forever. But a tree makes a decent first step.
 
6:43 PM
Yeah
you are talking about the Herb Sutter speech?
Tree is a good start, yes
 
Not particularly. Did Herb give a speech about bfs?
 
yeah
I mentioned it today
 
@DexterLiu Sorry--I didn't follow the thread back to the beginning.
 
he gave a 2 hour speech about tree and graph
back in 2016
xD
 
 
2 hours later…
8:32 PM
vis[x][y]==1; was my mistake
thing i learn that if you want to sleep ,you must sleep and then come back to get the problem :)
yes and KNMOVE.cpp:61:14: warning: value computed is not used [-Wunused-value]
vis[x][y]==1;
my bad
thanks @DexterLiu
 

« first day (1193 days earlier)      last day (1643 days later) »