« first day (351 days earlier)      last day (2508 days later) » 

11:57 AM
This is a bump message to keep the room from being frozen
 
Ven
mgottem
 
@Mgetz you only need a bump once a week though
 
@ratchetfreak darn, bumped early then
 
12:49 PM
I will do it every day :D
 
 
1 hour later…
1:59 PM
IME room freeze only happens after 2 weeks of inactivity
 
nwp
2:11 PM
Let's pretend we helped the whole internet and that the room fulfilled its purpose.
 
2:41 PM
hi guys
I have a silly questions about "sentinels"
in circular doubly linked list
I was wondering if the "correct way" was just putting an extra node nil
or maybe just using two pointers where one of the two represents the sentinel
something like
struct Node {
 Node* next;
 Node* prev;
};

struct List {
  Node* sentinel;
  Node* first;
};
O geez, actually my struct List is a crap
but basically I'm not sure whether
I declare a list, the space for the sentinel node should be allocated or not
or maybe it would be easier just cover all the corner cases when you have <code>nullptr</code>
 
you can lazy allocate it when needed
make sure it's allocated on first push
 
user8109089
i want to use range based for loop to parametr array. But it makes error. what is the reason for that ? void Myalgo::printArray(int arr[]) { for (int i : arr) { cout << i << ","; } }
 
arr[] doesn't have any length information
so the compiler has no way of testing the bounds
 
So it would be correct to declare my list like
 
user8109089
ya but i can't give it inside the function bcz it can be vary
 
Ven
2:46 PM
@Nuwan722 is that supposed to be C++?
 
user8109089
yeah
 
Ven
@Nuwan722 int arr[] doesn't carry length information. you can't do that. use a std::vector.
 
@Nuwan722 then pass a const std::vector&
 
struct List {
public:
  List();
private:
  Node* sentinel;
};

List::List() {
 sentinel = new Node();
 sentinel->next = sentinel;
 sentinel->prev = sentinel;
};
 
Ven
@user8469759 areyou writing a doubly linked list for school?
 
2:48 PM
not really, just reviewing basic concepts
I usually use the stl library
but once in a while is good reviewing
 
linked lists are going out of fashion though
 
really?
 
something about bad cache behavior
 
I see... anyway
would the declaration I posted be correct for a sentinel implementation? (again, it's a cirucalr doubly linked list
 
there are a few ways of creating a circular doubly linked lists though
 
2:51 PM
writing down some, I'll show you in a sec
 
3:19 PM
can u see the code?
 
@user8469759 Use ideone or coliru
 
ok
is this a good implementation of a circular doubly linked list with sentinel?
 
hello :)
 
I kept it simple on purpose because I was more interested in the pointer handling
again I repeat I'm never sure whether or not I understand the concept of sentinel node
 
3:33 PM
seems to be ok, but I only skimmed over it
 
ok now another question
assuming you're familiar with what a fibonacci heap is
there the node
has 4 pointers instead of 2
 
sorry probably won't be able to help you with that one
 
and vertically speaking the nodes are linked in a doubly circular linked list in that case
and I was wondering If given my list struct/class
would be a good idea to extend the node
 
fibonacci heaps are famous for their legendary implementation difficulty
 
(like red black trees)
and therefore supports the other operations
well.. I need just a guideine on how to proceed
 
3:36 PM
haven't bothered to even look at the fibonacci heaps because "Introduction to algorithms" by Cormen et al said something along "has barely found practical use but they're quite interesting from the theoretical standpoint"
 
given that a good practice is always software reuse
 
 
4 hours later…
8:03 PM
I have weird error. I create public Pointers to QLineEdits then I put all those items to vector that then I send to function to loop over and create. But each time I run it I get random memory gibberish like 0 or 0xffffffff or a bunch of 0x256ab7c0
any idea how I can debug that issue?
I'm new to C++ and I'm lost :- (
here ist he function
void qWGen::genQLineEdits(vector<QLineEdit *> qLineEdits) {
for (int i = 0; i < qLineEdits.size(); i++) {
qLineEdits[i] = new QLineEdit();
};
}
 
4 messages moved from Lounge<C++>
you're modifying a copy
 
humh
 
pass by reference instead
 
in header I made this in private:
vector<QLineEdit*> lineEdits;
QLineEdit *projectName;
in CPP I got this
lineEdits = {projectName}
 
millennium means the vector is a copy of the original.
 
8:07 PM
then I just:
genQLineEdits(lineEdits);
millennium is > * ?
 
@Dariusz this code does nothing except leaking memory
 
void qWGen::genQLineEdits(vector<QLineEdit *> qLineEdits) should be
 
isnt that what I got ? o.o
 
void qWGen::genQLineEdits(vector<QLineEdit *>& qLineEdits), this accesses the original vector, not your function-local copy.
 
aaaaaaaaaaa
 
8:08 PM
IOW
1 min ago, by milleniumbug
pass by reference instead
 
Is lineEditssized appropriately?
 
what you mean?
 
oh, nevermind, I read the loop wrong
didn't see you were grabbing the size from the vector
 
I tried sizeof(qLineEdits) and qLineEdits.size(),
sizeof returned 12 for some reason
size returned 19 < which it is
 
sizeof isn't what you want
 
8:11 PM
yeh I need size correct?
 
sizeof returns the size of the variable in bytes
 
yes
 
oh
ok
I still got 0's
:- (
when I create header I create the vector this way >
vector<QLineEdit*> lineEdits;

Is this correct?
 
that should be right.. are you ever adding anything to the vector before it goes into the genQLineEdits function?
 
this creates an empty vector, yes
 
8:12 PM
in cpp I made this
lineEdits = {projectName, projectPath}//+ more items
do I need to add * to each item?
like lineEdits = {*projectName, *projectPath} ?
 
yeah no
also you're assigning garbage to lineEdits
 
oh dear
 
projectName and projectPath are uninitialized pointers
 
how should I assign these items to vector?
I made pastebin
as I'm lost :- (
 
yeah that doesn't help
try pasting your actual code
 
8:18 PM
I've updated the paste > pastebin.com/cXaehrRy
does this help?
 
no, like your actual code
this doesn't compile
 
ah
give me a bit
leme make it up
 
So your vector probably has good values in it, but that's not going to update the pointers projectName and projectPath
you copied the values (garbage values, at that) of projectName and projectPath into a vector, then overwrote them in getQLineEdits, never touching the projectName and projectPath variables in the process.
 
ok got test written
leme just make pastebin
this print out 4 items then it crashes
Process finished with exit code -1073741819 (0xC0000005)
 
8:33 PM
yeah as expected
 
What did I do wrong?
 
Hello, i wanna visit all node of a graph with minimum cost( revisiting node/edge is allowed )
what's the approach ?
 
get all nodes, visit them
 
@milleniumbug Can you maybe post an snipped or something? I'm really new to the C++ and all the reference/poinets/etc still cause me a lot of pain to manage....
 
// lineEdits is empty at this point, all the project* point at garbage
lineEdits = {projectName, projectPath,projectPatha,projectPathb,projectPathbc};
// lineEdits is pointing at the same garbage project* pointers to
genQLineEdits(lineEdits);
// now all the pointers in the vector point to valid QLineEdits, but the project* contain garbage
lay->addWidget(projectName); // adding a garbage widget
 
8:41 PM
so I cant use vector to generate my items and I need to do this in my mainWindow.cpp ?
projectName = new QLineEdit();
projectPath = new QLineEdit();
projectPatha = new QLineEdit();
projectPathb = new QLineEdit();
projectPathbc = new QLineEdit();
 
are you using that vector for anything else
 
I use it later to get items data
but I havent got to that part yet
I wanted to have vector of widgets to do get.text(), setText()
so I can store it in json to hdd/etc
 
well, I'd start with "don't fill the vector that way"
 
oh
I though what I had was a vector of poinets to memory that then I filled with QLineEdits
 
because I don't have Qt installed atm, I'll write an equivalent simple program that operates on a vector and on ints instead of QLineEdits without Qt and you'll have to manage
 
8:48 PM
very, very new to both C and C++, would this function be terribly hard to convert to C++? pastebin.com/M0DMYnuR
 
probably not, just remove some warts (like the register keyword) and it should compile already
 
Humhhhhhhhhh I'm processing it, thank you!
so I replaced my mainWidget.cpp with this one
so if I understand correctly. I need to add QLineEdits to array 1st, then reference them back to my projectName/etc items and then I can create them again using my function
wait
I dont have to create them again using my function o.o
I just create them backward-isch...
heeeeeeeeeeee mysterious as hell.
thank you!
 
9:23 PM
but this only shifts the code I still have to have 20 entries that are
something = vector[0]
something = vector[1]
something = vector[2]
something = vector[3]
so that the 20 items have a pointer in private/public that I can access
 
@milleniumbug since I'm trying to compile with Rcpp it seems there are additional stipulations... what would need to be done to have it return to as a unsigned instead of modifying the object passed by reference (a guess -- not really sure whats going on)? pastebin.com/H4X0pubT
 
well you do need to repeat the names anyway
 
I though I can create QLineEdit name type/pointer in header, that then I add to array, that then loop over and create QLineEdit for each pointer. But that seems to be not working as the initial pointer points to garbage
so weird how do people make these qui generators o.o
 
@mlegge personally I'd make as little changes to that code as possible, it's quite bad
one option would be to introduce another function that calls it
that function would pass the address to the local unsigned variable, and then return the value
 
9:40 PM
alright I'll try that -- and whats particularly bad about it so if I attempt to re-write myself I don't make the same mistake
 
 
2 hours later…
11:31 PM
I have a small problem, my derived class constructor isn't being called even though the base class constructor is. I've already tried calling std::cout from within the constructor and nothing returns.
Here's some simple code from it
class Orb : public Block {
public:
// Constructor
using Block::Block;
Orb(int x, int y, Power nPower);
};
and then the include
Orb::Orb(int x, int y, Power nPower) : Block::Block(x, y, blockOrbFreeze) {
power = nPower;
}
am I missing something obvious? it doesn't work for other derived classes either
Just to add more detail, the base class is derived from another class, and every single function/constructor being called from the derived class is only running the base class functions
 

« first day (351 days earlier)      last day (2508 days later) »