int k = 30; main() { int k = 50; adder(30); } int adder(int operand) { int k = operand + 40; printer(); } void printer() { printf("k = %d\n", k); }What value will be printed for k by printer assuming:
#include <iostream> #include <string> extern bool edit_mode; class Button { protected: string label; class HandleButtonSelection { protected: void handleEvent() { cout << label << endl; edit_mode = true; } } public: Button(string myLabel) { label = myLabel; } };Make the following assumptions:
outputstream cout;and a declaration for the outputstream class. outputstream is assigned a scope id of 2. Its category is "type" and its "other" information is "class scope 2".
bool: 2 string: 5 edit_mode: 5 cout: 5 label: 6 Button: 6 handleEvent: 1 HandleButtonSelection: 3 myLabel: 0
struct addr { char *street; char *city; char *state; int zipcode; } struct worker { char *name; struct addr *address; } struct worker *employee;hint: think about the "with" statement discussed in class and how the strategy used for "with" statements might be adapted to work with this chain of references.
class GraphicalObject { protected: int left; int top; } class BoxObject : public GraphicalObject { protected: int width; int height; } class Rectangle : public BoxObject { public: void draw(GraphicsContext g) { g->drawRect(left, top, width, height); } }Assume a LeBlanc-Cook style symbol table and algorithm for resolving variable name references. In the draw method, the resolution algorithm must have a way of finding the symbol table records for left, top, width, height. However, since Rectangle is not physically nested within either BoxObject or GraphicalObject, the scope records for BoxObject and GraphicalObject will not be on the scope stack when the draw method for Rectangle gets processed by the compiler. Propose a strategy for how the compiler might find the symbol table information for left, top, width, and height. Your strategy will need to discuss: