0.0测试配套源代码

FUN2.h

//
// Created by Administrator on 2026/3/23.
//

#ifndef CMD_FUN2_H
#define CMD_FUN2_H
#include <stdio.h>

class FUN2 {
public:
    int testFun2();
};


#endif //CMD_FUN2_H

FUN2.cpp

//
// Created by Administrator on 2026/3/23.
//

#include "FUN2.h"

int FUN2::testFun2() {
    printf("FUNC2 FUNC2 FUNC2\n");
    return -4;
}

main.cpp

#include <cstring>
#include <iostream>
#include "FUN2.h"

#define MAX (9988)

int g_num;

class FUNC {
public:
    void testFun1() {
        printf("FUNC1 FUNC1 FUNC1\n");
    }
};

void testFun(std::string str) {
    printf("str:%s\n", str.c_str());

    str = "vvvv";
    g_num = 222;

    printf("str:%s\n", str.c_str());
}

int testFun(int num) {
    printf("num:%d\n", num);

    int cnt = 199;
    g_num = 111;
    printf("cnt:%d\n", cnt);

    return -2;
}


int main(int argc, char *argv[]) {

    int a = 123;
    char buf[128] = "456";
    std::string str = "abc";

    for (int i = 0; i < argc; i++) {
        printf("argv[%d]:%s\n", i, argv[i]);
    }

    testFun(MAX);

    strcpy(buf,"zzxx");
    printf("buf:%s\n",buf);

    testFun("xxxx");

    FUNC f;
    f.testFun1();

    FUN2 f2;
    f2.testFun2();

    int sum=0;
    for(int i =0;i<10000;i++){
        sum+=i;
    }

    return 0;
}

编译方式

g++ main.cpp FUN2.h  FUN2.cpp -o cmd -g
posted @ 2026-05-19 22:56  BlackSnow  阅读(12)  评论(0)    收藏  举报