   C++ Program Exam for a Job
  I just took a programming test for a software engineering position and for the most part I think I aced it. However when I got home I realized I did something really silly. The object of the exam was to create a class Node for a queue and use it in a queue. So here is what I did for the Node class.class Node{ public:  string getItem();  string getItem2(); private:  string Item;  string Item2;  Node* link;};Simple enough basically creating a Node that has two data values both of type string.Then I implemented the queue operations I will only show the push(Node d). Here is the pushvoid Queue::push(Node d){  if(front == NULL)  {    front = new Node;    front->Item = d.getItem;    front->Item2 = d.getItem;    front->link = NULL;    back = front;  }  else  {    // know how to do but not important to my question  }}So after I got home I realized that front (which is a private member in Queue labeled Node* front, back is the same Node* back) can not directly access Item as I have done in the above. I didn't even think about it until I was home and said oh crap I can't access it that way! Anyhow if you were hiring and you saw that I implemented the push and pop correct just obviously whiffed the fact that Item and Item2 are private, would you still hire someone who made such a silly mistake?  
  Nobody would expect you to be able to write 100% perfect code without a compiler to even verify syntax errors. The point of programming excerises is not so much to see that you know how to solve that particular problem, but to see how you solve problems in general. So minor problems like the one you described are not going to mean much...   ;Quote:Original post by CodekaNobody would expect you to be able to write 100% perfect code without a compiler to even verify syntax errors. The point of programming excerises is not so much to see that you know how to solve that particular problem, but to see how you solve problems in general. So minor problems like the one you described are not going to mean much...Or will it?!Just kidding, and I agree.  Even exams for my classes (in high school and university) are more lenient for small things like that.   ;  That's probably not something to worry about. However, the fact that you used:void Queue::push(Node d)rather thanvoid Queue::push (const Node& d)would definitely catch my attention while reviewing the exam.;Quote:Original post by Fibonacci OneThat's probably not something to worry about. However, the fact that you used:void Queue::push(Node d)rather thanvoid Queue::push (const Node& d)would definitely catch my attention while reviewing the exam.Is the reason because 1) its more efficient (only passing a reference) and 2) const ensures that you wont alter d?I am trying to get better at learning more proper c++ =/   ;Quote:Original post by CrazyfoolQuote:Original post by CodekaNobody would expect you to be able to write 100% perfect code without a compiler to even verify syntax errors. The point of programming excerises is not so much to see that you know how to solve that particular problem, but to see how you solve problems in general. So minor problems like the one you described are not going to mean much...Or will it?!Just kidding, and I agree.  Even exams for my classes (in high school and university) are more lenient for small things like that.I had a university professor who would deduct points for "incorrect" indentation and formatting in handwritten code in exams.;Quote:Original post by CrazyfoolQuote:Original post by Fibonacci OneThat's probably not something to worry about. However, the fact that you used:void Queue::push(Node d)rather thanvoid Queue::push (const Node& d)would definitely catch my attention while reviewing the exam.Is the reason because 1) its more efficient (only passing a reference) and 2) const ensures that you wont alter d?I am trying to get better at learning more proper c++ =/(1) and (2). You pass the reference because if you don't it will call the copy constructor to create a new Node (unnecessary work). You make it const because now that it's a reference you don't want the function to be able to modify it.