support bazel complie this project and format code.
This commit is contained in:
23
basic_content/const/funciton_const/condition2/BUILD
Normal file
23
basic_content/const/funciton_const/condition2/BUILD
Normal file
@@ -0,0 +1,23 @@
|
||||
# please run `bazel run basic_content/const/funciton_const/condition2:condition1`
|
||||
# please run `bazel run basic_content/const/funciton_const/condition2:condition2`
|
||||
# please run `bazel run basic_content/const/funciton_const/condition2:condition3`
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary")
|
||||
|
||||
cc_binary(
|
||||
name = "condition1",
|
||||
srcs = ["condition1.cpp"],
|
||||
copts = ["-std=c++11"]
|
||||
)
|
||||
|
||||
# Don't panic if you get compilation errors, this is what this code demonstrates, as expected.
|
||||
cc_binary(
|
||||
name = "condition2",
|
||||
srcs = ["condition2.cpp"],
|
||||
copts = ["-std=c++11"]
|
||||
)
|
||||
|
||||
cc_binary(
|
||||
name = "condition3",
|
||||
srcs = ["condition3.cpp"],
|
||||
copts = ["-std=c++11"]
|
||||
)
|
Binary file not shown.
@@ -1,10 +1,9 @@
|
||||
#include<iostream>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
|
||||
int num=0;
|
||||
int * const ptr=# //const指针必须初始化!且const指针的值不能修改
|
||||
int * t = #
|
||||
*t = 1;
|
||||
cout<<*ptr<<endl;
|
||||
int main() {
|
||||
int num = 0;
|
||||
int *const ptr = # // const指针必须初始化!且const指针的值不能修改
|
||||
int *t = #
|
||||
*t = 1;
|
||||
cout << *ptr << endl;
|
||||
}
|
||||
|
@@ -1,8 +1,7 @@
|
||||
#include<iostream>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
|
||||
const int num=0;
|
||||
int * const ptr=# //error! const int* -> int*
|
||||
cout<<*ptr<<endl;
|
||||
int main() {
|
||||
const int num = 0;
|
||||
int *const ptr = # // error! const int* -> int*
|
||||
cout << *ptr << endl;
|
||||
}
|
||||
|
Binary file not shown.
@@ -1,8 +1,7 @@
|
||||
#include<iostream>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
|
||||
const int num=10;
|
||||
const int * const ptr=# //error! const int* -> int*
|
||||
cout<<*ptr<<endl;
|
||||
int main() {
|
||||
const int num = 10;
|
||||
const int *const ptr = # // error! const int* -> int*
|
||||
cout << *ptr << endl;
|
||||
}
|
||||
|
Reference in New Issue
Block a user