We still remember that the specification on the C++ is like static memeber can not extern.
But once, we might do that.
1. Include class.
class-name:
2. Extern an inclusion of double pointer ** of the class:
inclusion-name.h
extern **class-name arry_class_name
3. Allocation double pointer ** of the class in main-lootin.
**class-name arry_class_name = (**class-name) malloc (sizeof(*class-name) * number );
Our compilation and execute.
1 |
allocation.h allocation.cpp static vPoint** allocation = nullptr;
|
v | 2/26 |
2 |
main.cpp allocation = (vPoint**) malloc ( sizeof(vPoint*) * 3 ); |
v | 2/26 |
3 |
allocation.h extern static vPoint** allocation; |
x | 2/26 |
4 | We have to ensure the aboves. | ||
5 | |||
6 |
https://github.com/WaitrudWeber/source_zip/blob/master/static_declare_20210226.zip
> winmain_001.exe
we could allocate the static memories |00641118|
How do we include loca value in the other source code.
1 | local code block |
to other code block |
bye use of |
2 |
allocation.cpp static vPoint** allocation = nullptr; |
v |
allocation.h static vPoint** allocation = nullptr; *same declaration |
3 |
allocation.cpp vPoint** allocation = nullptr; |
v |
allocation.h extern vPoint** allocation; |
4 |
extern static vPoint** allocation; *we can not extern static. |
x | allocation.h
static vPoint** allocation = nullptr; |
Proofment of 4 is the below.
---
> c:\aaa\bin\make.exe clean
del main.o vPoint.o allocation.o
> c:\aaa\bin\make.exe all
mingw32-g++ -Wall -O3 -I C:\MinGW\include\ -L C:\MinGW\lib -lgdi32 -lws2_32 -lwsock32 -mwindows -o main.o -c main.cpp
mingw32-g++ -Wall -O3 -I C:\MinGW\include\ -L C:\MinGW\lib -lgdi32 -lws2_32 -lwsock32 -mwindows -o vPoint.o -c vPoint.cp
p
vPoint.cpp: In member function 'int vPoint::setPoint(float, float, float)':
vPoint.cpp:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
mingw32-g++ -Wall -O3 -I C:\MinGW\include\ -L C:\MinGW\lib -lgdi32 -lws2_32 -lwsock32 -mwindows -o allocation.o -c alloc
ation.cpp
allocation.cpp:8:24: error: conflicting specifiers in declaration of 'allocation'
extern static vPoint** allocation;
^~~~~~~~~~
make: *** [Makefile:23: allocation.o] Error 1
---
https://github.com/WaitrudWeber/source_zip/blob/master/static_declare_20210227-001.zip
---
Writing: Very thanks to:
[1] How to Make a Living Wall: https://www.wikihow.com/Make-a-Living-Wall