private and public in namespace cpp
C++
// thing.cpp
namespace thing
{
namespace // anonymous namespace
{
int x = 1;
int y = 2;
int sum(int a, int b)
{
return a + b;
}
}
int getX()
{
return x;
}
int getSum()
{
return sum(x, y);
}
};
#include <cstdio>
#include "thing.hpp"
int main(int argc, char **argv)
{
printf("%d\n", thing::getX()); // OK
printf("%d\n", thing::getSum()); // OK
printf("%d\n", thing::sum(1, 2)); // error: ‘sum‘ is not a member of ‘thing’
printf("%d\n", thing::y); // error: ‘y‘ is not a member of ‘thing’
}
Also in C++:
- Title
- accept the noun and the output of plural c++
- Category
- C++
- Title
- nth_element c++
- Category
- C++
- Title
- c++ clear console
- Category
- C++
- Title
- c++ short if
- Category
- C++
- Title
- fast input output in c++
- Category
- C++
- Title
- making random numbers in c++
- Category
- C++
- Title
- Convert binary tree to a doubly linked list
- Category
- C++
- Title
- how to find the number of cycles in a graph C++
- Category
- C++
- Title
- hobo 8
- Category
- C++
- Title
- min heap priority queue c++
- Category
- C++
- Title
- recursion in cpp with reference
- Category
- C++
- Title
- c++ cout int
- Category
- C++
- Title
- convert int to string c++
- Category
- C++
- Title
- how to run a c++ program in the background
- Category
- C++
- Title
- c++ switch case statement
- Category
- C++
- Title
- how to check type in c++
- Category
- C++
- Title
- array<string, 7> c++
- Category
- C++
- Title
- what is difffrence between s.length() and s.size()
- Category
- C++
- Title
- first fit algorithm
- Category
- C++
- Title
- modulo c++
- Category
- C++
- Title
- c++ typeid get type name
- Category
- C++
- Title
- c++ char print width
- Category
- C++
- Title
- compare values within within a vector c++
- Category
- C++
- Title
- 1d fixed length arrays c++
- Category
- C++
- Title
- substitution failure is not an error
- Category
- C++
- Title
- cpp loop through object
- Category
- C++
- Title
- c++ template function
- Category
- C++
- Title
- c++ uint32_t
- Category
- C++
- Title
- how to use a new node c++
- Category
- C++
- Title
- check if intent has extras
- Category
- C++
- Title
- UPARAM(ref)
- Category
- C++
- Title
- sub string of vector c++
- Category
- C++
- Title
- object reference not set to an instance of an object c#
- Category
- C++
- Title
- accumulate in cpp
- Category
- C++
- Title
- ue4 c++ enum
- Category
- C++
- Title
- sqrt in c++
- Category
- C++
- Title
- in c, is class uppercase or lowercase
- Category
- C++
- Title
- c++ vector lower_bound index
- Category
- C++
- Title
- c++ argv
- Category
- C++
- Title
- mark occurances of elements in array cpp
- Category
- C++
- Title
- rgb(100,100,100,0.5) validation c++
- Category
- C++
- Title
- how to include seld declared header file in c++
- Category
- C++
- Title
- bitset c++
- Category
- C++
- Title
- how to print a 2d array in c++
- Category
- C++
- Title
- when ratings will be updated for codechef
- Category
- C++
- Title
- c++ iterate over vector
- Category
- C++
- Title
- convert integer to string c++
- Category
- C++
- Title
- gfg right view of tree
- Category
- C++
- Title
- for c++
- Category
- C++
- Title
- c++ assert
- Category
- C++
- Title
- maximum subarray sum equal with K in c++
- Category
- C++
- Title
- pair in c++
- Category
- C++
- Title
- Runtime Error: Runtime ErrorFloating-point exception (SIGFPE
- Category
- C++
- Title
- how to dynamically allocate an array c++
- Category
- C++
- Title
- how to reverse a vector
- Category
- C++
- Title
- can you use rand to read in from an external file inc++
- Category
- C++
- Title
- c++ triple
- Category
- C++
- Title
- how to make a 2d vector in c++
- Category
- C++
- Title
- pass by reference c++
- Category
- C++
- Title
- how to delete an element in vector pair in cpp
- Category
- C++
- Title
- how to get input from the console in c++
- Category
- C++
- Title
- c++ evaluate expression
- Category
- C++
- Title
- double to float c++
- Category
- C++
- Title
- split 2d array into chunks in c++
- Category
- C++
- Title
- how to format decimal palces in c++
- Category
- C++
- Title
- clear file before writing c++
- Category
- C++
- Title
- modular exponentiation c++
- Category
- C++
- Title
- case label in c++
- Category
- C++
- Title
- private and public in namespace cpp
- Category
- C++
- Title
- queue stl c++
- Category
- C++
- Title
- gta san andreas
- Category
- C++
- Title
- pyqt connect
- Category
- C++
- Title
- first prime numbers
- Category
- C++
- Title
- c++ tutorial
- Category
- C++
- Title
- c++ cli convert string to string^
- Category
- C++
- Title
- Insert into vector C++
- Category
- C++
- Title
- how to sort a vector in c++
- Category
- C++
- Title
- function declerations in C++
- Category
- C++
- Title
- c++ delete printed characters
- Category
- C++
- Title
- c++ scanf
- Category
- C++
- Title
- c++ char print align
- Category
- C++
- Title
- c++ pointers
- Category
- C++
- Title
- c++ enum rand
- Category
- C++
- Title
- if not defined c++
- Category
- C++
- Title
- c++ string to integer without stoi
- Category
- C++
- Title
- coronavirus
- Category
- C++
- Title
- c++ create array
- Category
- C++
- Title
- & in xml
- Category
- C++
- Title
- sort function in c++
- Category
- C++
- Title
- *min_element in c++
- Category
- C++
- Title
- convert decimal to binary in c++
- Category
- C++
- Title
- traverse a map
- Category
- C++
- Title
- new class * [] c++
- Category
- C++
- Title
- kruskal c++
- Category
- C++
- Title
- namespace c++
- Category
- C++
- Title
- how to check datatype of a variable in c++
- Category
- C++
- Title
- get index of value c++
- Category
- C++
- Title
- c++ replace n substrings
- Category
- C++
- Title
- -> cpp
- Category
- C++
- Title
- properties of a set c++
- Category
- C++