好吧,基本上对于一个类我需要创建一个使用模板的简单程序,在这个程序中我收到用户的数据,我不知道它的类型,直到我收到它。
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "il.co.dotech.constinspect"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.schibstedspain.android:leku:2.3.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.firebase:firebase-storage:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.firebase:firebase-database:11.8.0'
compile 'com.google.firebase:firebase-auth:11.8.0'
compile 'com.google.android.gms:play-services-auth:11.8.0'
compile 'com.google.android.gms:play-services-maps:11.8.0'
compile 'com.google.android.gms:play-services-location:11.8.0'
//compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.facebook.android:facebook-android-sdk:4.26.0'
compile'com.android.support:support-v4:25.3.1'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile'com.android.support:recyclerview-v7:25.0.0'
compile 'com.github.medyo:fancybuttons:1.8.2'
compile 'com.github.Mariovc:ImagePicker:1.0.4'
compile 'com.github.clans:fab:1.6.4'
compile 'com.squareup.okhttp3:okhttp:3.4.2'
compile 'org.json:json:20160212'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
compile'com.daimajia.swipelayout:library:1.2.0@aar'
compile 'com.mobsandgeeks:android-saripaar:2.0.3'
compile 'com.mikepenz:actionitembadge:3.3.1@aar'
compile 'com.mikepenz:iconics-core:2.8.1@aar'
compile 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar'
testCompile 'junit:junit:4.12'
compile files('libs/gson-1.7.1.jar')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
apply plugin: 'com.google.gms.google-services'
我知道问题是一开始的模板部分,但是我需要更改几种类型的类型我真的不知道该怎么做。很可能因为模板它没有检测到我的main()函数作为主要并且给了我"标题错误LNK2019"
答案 0 :(得分:0)
这不起作用,因为链接器无法找到main
。此外,它没有意义,因为您只能运行main
一次,并且您应该知道在任何给定的调用中T
具有哪种类型。 : - )
如果您只想使用T
作为占位符,请使用typedef
声明(或等效的using
声明),如下所示:
int main() {
using T = int;
Calculator<T> calc;
// rest of code here
// ...
}