如何设置枚举类型提示的默认值,我尝试将其设置为 0 或 1,或者什么都不设置,但出现相同的错误?
enum tip {
pop,
rap,
rock
};
class Pesna{
private:
char *ime;
int vremetraenje;
tip tip1;
public:
//constructor
Pesna(char *i = "NULL", int min = 0, tip t){
ime = new char[strlen(i) + 1];
strcpy(ime, i);
vremetraenje = min;
tip1 = t;
}
};
Run Code Online (Sandbox Code Playgroud) 编译代码时,我收到此错误:找不到名称SimpleChanges.我是Angular 2的新手,你能帮我找到错误的位置吗?这是我的家.
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {Observable} from 'rxjs/Rx';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
date: Date;
constructor(public navCtrl: NavController) {
this.date = new Date();
}
ticks = 0;
ngOnChanges(changes: {[propertyName: string]: SimpleChanges}){
if(changes['ticks']){
if(this.ticks == 20)
this.ticks = 0;
}
}
ngOnInit(){
let timer = Observable.timer(0,1000);
timer.subscribe(t=>this.ticks = t);
};
}
Run Code Online (Sandbox Code Playgroud) className &temp (someOtherclassName &c)
Run Code Online (Sandbox Code Playgroud)
问题是我应该返回什么我试图返回一个在类中新创建的对象,它不起作用,我也尝试返回引用或指针,它不起作用.
Klub &novKlub(Clen &c){
Klub newKlub;
strcpy(newKlub.name, name);
for(int i = 0; i < elements; i++){
if(c.getLevel() == clenovi->getLevel()){
newKlub += clenovi[i];
}
}
return newKlub;
}
Run Code Online (Sandbox Code Playgroud)
这是所有代码:
#include<iostream>
#include<cstring>
using namespace std;
class Clen{
private:
char name[50];
char surname[50];
int level;
public:
Clen(char n[] = "null", char s[] = "null", int l = 1){
strcpy(name, n);
strcpy(surname, s);
level = l;
}
//operator++
Clen operator++(int){
Clen temp(*this);
++level;
return temp;
}
//++operator
Clen &operator ++ …Run Code Online (Sandbox Code Playgroud)