Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
4003CEM-pointers/lab_pointer.h
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
14 lines (12 sloc)
1.29 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <array> | |
#include <string> | |
#include <iostream> | |
using namespace std; | |
void test_int( int *ptr ) { cout << "An int takes " << sizeof(*ptr) << " bytes but a pointer to one takes " << sizeof(ptr) << " bytes" << endl; } | |
void test_uint( unsigned int *ptr ) { cout << "An unsigned int takes " << sizeof(*ptr) << " bytes but a pointer to one takes " << sizeof(ptr) << " bytes" << endl; } | |
void test_short( short *ptr ) { cout << "A short takes " << sizeof(*ptr) << " bytes but a pointer to one takes " << sizeof(ptr) << " bytes" << endl; } | |
void test_char( char *ptr ) { cout << "A char takes " << sizeof(*ptr) << " bytes but a pointer to one takes " << sizeof(ptr) << " bytes" << endl; } | |
void test_float( float *ptr ) { cout << "A float takes " << sizeof(*ptr) << " bytes but a pointer to one takes " << sizeof(ptr) << " bytes" << endl; } | |
void test_double( double *ptr ) { cout << "A double takes " << sizeof(*ptr) << " bytes but a pointer to one takes " << sizeof(ptr) << " bytes" << endl; } | |
void test_string( string *ptr ) { cout << "A string takes " << sizeof(*ptr) << " bytes but a pointer to one takes " << sizeof(ptr) << " bytes" << endl; } | |
void test_array( array<int,10> *ptr ) { cout << "An array of 10 elements takes " << sizeof(*ptr) << " bytes but a pointer to one takes " << sizeof(ptr) << " bytes" << endl; } | |