online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/*************************************************************** * Name: Rafael Orta * Course: Computer Science & Programming * Class: CS04103 Section: 4 &5 * Assignment Date: 04/15/18 * File Name: friendClass.cpp ***************************************************************** * ID: Lecture 11-2 * Purpose: Example of a friend of a class *****************************************************************/ #include <stdio.h> #include <iostream> using namespace std; class Test { public: Test() { TestVar = 0; } private: int TestVar; // Remember private objects can only be accessed by members of the class and friends of the class. // The Class is declaring that the function definition below is a friend thus trusted friend void TestFriend(Test& tvo); }; // Note that the clause above is inside the class definition. // Below is the function definition for TestFriend, please notice how you can access the variable TestVar // from the class even that it is declared private. void TestFriend (Test& tvo) { tvo.TestVar = 99; cout << tvo.TestVar << endl; } int main() { Test C1; TestFriend(C1); return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue