[ create a new paste ] login | about

Link: http://codepad.org/POMKzKhh    [ raw code | output | fork ]

C++, pasted on Sep 1:
// common.hpp
#ifndef _COMMON_HPP_ 
#define _COMMON_HPP_

const int a = 10;
 
#endif 

// first.cpp
#include "common.hpp"
#include <iostream> 

void firstPrint()
{
   std::cout << static_cast<void*>( const_cast<int*>( &a ) ) << std::endl;
}

// second.cpp
#include "common.hpp"
#include <iostream>
 
void secondPrint()
{
   std::cout << static_cast<void*>( const_cast<int*>( &a ) ) << std::endl;
}

// main.cpp

#include <cstdlib>
#include <iostream>

#include "common.hpp"

extern void firstPrint(); 
extern void secondPrint();

int main(int argc, char *argv[])
{
    firstPrint();
    secondPrint();
    
    std::cout << static_cast<void*>( const_cast<int*>( &a ) ) << std::endl; 
     
    std::cin.get();
}


Output:
1
Line 21: error: common.hpp: No such file or directory


Create a new paste based on this one


Comments: