小编Sem*_*etg的帖子

在1处启动数组索引是否存在问题?

我的老师通常从一个开始索引数组.所以,基本上,当我们需要他使用的100个元素的数组时

int a[101] 
Run Code Online (Sandbox Code Playgroud)

代替

int a[100]
Run Code Online (Sandbox Code Playgroud)

例如,他像这样填写:

for (int i = 1; i <= 100; i++)
    cin >> a[i];
Run Code Online (Sandbox Code Playgroud)

使用这种方法有什么问题,还是应该避免使用?(从0开始处理索引时没有任何问题)

c++ arrays

4
推荐指数
1
解决办法
367
查看次数

"使用operator +是不明确的",尽管类型转换被声明为显式

我一直试图建立一个小型库来处理大整数,就像练习一样,但我没有明显的理由得到这个错误:

使用重载运算符'+'是不明确的(操作数类型'BigNum :: BigInt'和'int')

这是类定义:

namespace BigNum {

    class BigInt {
    public:
        BigInt();
        BigInt(int64_t n);
        BigInt(std::string s);

        friend std::istream& operator>> (std::istream& in, BigInt& n);
        friend std::ostream& operator<< (std::ostream& out, BigInt n);

        friend bool operator< (const BigInt& a, const BigInt& b);
        friend bool operator> (const BigInt& a, const BigInt& b);
        friend bool operator== (const BigInt& a, const BigInt& b);
        friend bool operator!= (const BigInt& a, const BigInt& b);
        friend bool operator<= (const BigInt& a, const BigInt& b);
        friend bool operator>= (const …
Run Code Online (Sandbox Code Playgroud)

c++ oop

2
推荐指数
1
解决办法
77
查看次数

标签 统计

c++ ×2

arrays ×1

oop ×1