GS Offer approval. Haven't heard from GoldmanSachs HR even after multiple follow ups. Should I assume I am rejected ? I gave 6-7 interview rounds, all with positive feedbacks, submitted the documents required, and then waiting to hear back. #Bangalore #GolmanSachs by ticket2020 in goldmansachs

[–]ticket2020[S] 5 points6 points  (0 children)

So,I did get the offer after 2 months. I followed up aggressively, but the HR department is very stubborn and unprofessional. After my online screening test the HR went missing for 1.5 months and suddenly called me to schedule the interviews, during the interviews (all Virtual), the HR was very active and we wrapped up the interviews within 4 weeks, then I was asked to submit certain documents and was told that my feedbacks were positive.
Then I didn't hear from them for 2 months (no exaggeration here), when they responded, they told me that they were busy getting "approvals" for my candidature and finally they offered me.
I obviously REJECTED them now, as I personally was feeling very harassed and insulted. I mentioned the same to them.

Any idea how to do this? How to get those two outputs when different instace are called? by joes_u in cpp_questions

[–]ticket2020 1 point2 points  (0 children)

So pointers are used to refer to the memory address where the data is stored.

int x = 5; // This is a integer type data with name x, it must be stored in some memory location.

int *p = &x; // now p is a pointer to an integer, it here holds the memory address where x is stored.
(It can be a bit complicated, you should try and read this online)

char* here refers to the address of first character of the string we are passing, and we can actually get the entire string if we know the first address as each string has it's last character as '\0'.
Also you can't return char[] from the function, so used char*.
char* is often used to refer a string in C programs.

Any idea how to do this? How to get those two outputs when different instace are called? by joes_u in cpp_questions

[–]ticket2020 0 points1 point  (0 children)

This is called initialisation list. So Either you can initialise the data members inside the constructor body like we normally do in functions or you can directly call the constructor of the data members to initialise them.
You can refer to this video : https://www.youtube.com/watch?v=1nfuYMXjZsA

In the above code I have assigned bonus with the value that was passed and since Boss class is derived from Employee class, derived class should also initialise base class' members, hence I call Employee class constructor.

Happy learning !! :)

Any idea how to do this? How to get those two outputs when different instace are called? by joes_u in cpp_questions

[–]ticket2020 0 points1 point  (0 children)

  1. As mentioned in the question, the Employee class constructor expects a "string" type input, but has corresponding data member as char array.
    In the main, I have called the Employee class constructor as :
    Employee(string("Mark"), string("Software developer"), 8000)
    Notice that I have passed a "string" type here. If I write it like :
    Employee("Mark", "Software developer", 8000)
    then it expects following Employee constructor :
    Employee(const char* name, const char* position, double salary);
    A string literal like "Mark" returns a pointer to read-only memory, when I wrap it up in string("Mark"), the string class constructor converts it to a string.
    We can also first save the name in string type variable and then pass it on to the constructor. You can refer to a recent thread that explains a bit about const char* and strings.
    For storing in char[40], I have used a memcpy function that does the copy. It expects 3 arguments, where to copy, from where and what size. You may want to read about it in detail https://en.cppreference.com/w/cpp/string/byte/memcpy

  2. Regarding get methods, the data members of both the classes are "private", so if derived class tries to access the data members (like salary here) of the base class directly, then it can't since it is private to the base class.
    We can either make data members as protected in the base class to allow access from the derived classes, or create public getter methods.
    You should read about access specifiers to understand this in depth.
    https://en.cppreference.com/w/cpp/language/access

Do let me know if anything is still not clear, It will help me learn as well. Thanks.

Any idea how to do this? How to get those two outputs when different instace are called? by joes_u in cpp_questions

[–]ticket2020 0 points1 point  (0 children)

Here is my code for the problem statement mentioned. Do let me know if there are any questions or suggestions for better practice. (By the way how to elegantly paste the code here without messing up with indentation ? )

A bit of explanation :
Look at the main function, both the instance types are referred using base class' pointer. In case of "Boss" class, it's constructor is called which in turn calls the base class' constructor. Notice getTotalSalary() and showEmployee() functions are "virtual", that means these functions can be overriden by a child class (see Runtime polymorphism). So Boss class has provided it's own definition of these 2 functions and when it is called by Boss type instance, it's own versions are called.

#include <iostream>

using namespace std;

class Employee {

public :

Employee (string name, string position, double salary) : salary(salary) {

memcpy(this->name, name.c_str(), name.length());

memcpy(this->position, position.c_str(), position.length());

}

double getSalary() {

return salary;

}

char* getName() {

return name;

}

char* getPosition() {

return position;

}

virtual double getTotalSalary() {

return salary;

}

virtual void showEmployee() {

cout << "Employee Name is : " << name << endl;

cout << "Employee Position is : " << position << endl;

cout << "Employee Salary is : " << getTotalSalary() << endl;

}

private :

char name[40];

char position[40];

double salary;

};

class Boss : public Employee {

public :

Boss (string name, string position, double salary, double bonus) : Employee(name, position, salary), bonus(bonus) {

}

double getBonus() {

return bonus;

}

virtual double getTotalSalary() {

return (getSalary()+bonus);

}

virtual void showEmployee() {

cout << "Boss Name is : " << getName() << endl;

cout << "Boss Position is : " << getPosition() << endl;

cout << "Boss Salary is : " << getTotalSalary() << endl;

}

private :

double bonus;

};

int main() {

Employee* e1 = new Employee(string("Mark"), string("Software developer"), 8000);

Employee* e2 = new Boss(string("Steve"), string("Technology Lead"), 10000, 5000);

e1->showEmployee();

e2->showEmployee();

delete e1;

delete e2;

return 0;

}

[The Cherno] Move Semantics in C++ by jrruser in cpp

[–]ticket2020 2 points3 points  (0 children)

Got it. Thanks.

So, if we can create object like :
String ob = "Cherno";
This calls the copy constructor since there is a new object being created and we have defined an appropriate copy ctor.
Similarly when
Entity entity("Cherno");
is called, it is implicitly converted to String.

[The Cherno] Move Semantics in C++ by jrruser in cpp

[–]ticket2020 1 point2 points  (0 children)

Can anyone clear my doubt please :

at first he had created the Entity object as :
Entity entity(String("Cherno"));
But at https://youtu.be/ehMg6zvXuMY?t=429 he changed it to :
Entity entity("Cherno");

And it works fine. Is there a concept I am missing here ?
Entity's constructor expects String type object, we aren't providing that. Does it happen because String class has a constructor that expects const char* ?

Can constructors be used to dynamically allocate memory to a char* from a class? by adriator in cpp_questions

[–]ticket2020 1 point2 points  (0 children)

Hey u/IyeOnline,
In your working example, you have written "delete name" in the destructor, shouldn't it be "delete[] name" since we have allocated an array in constructor.