我在C ++中执行以下程序,但是没有编译。请帮助找到问题
**Here is my gradle code:**
import org.jooq.util.jaxb.*
import org.jooq.util.*
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.h2database:h2:1.4.186'
classpath 'org.jooq:jooq-codegen:3.9.1'
classpath 'com.microsoft.sqlserver:sqljdbc4:4.0'
classpath "io.ratpack:ratpack-gradle:0.9.7-SNAPSHOT"
classpath 'com.github.jengelman.gradle.plugins:shadow:1.0.2'
}
}
plugins {
id 'io.ratpack.ratpack-java' version '1.3.3'
}
repositories {
jcenter()
}
dependencies {
compile ratpack.dependency('hikari')
compile 'com.h2database:h2:1.4.186'
compile 'org.jooq:jooq:3.9.1'
compile 'com.microsoft.sqlserver:sqljdbc4:4.0'
compile "io.ratpack:ratpack-gradle:0.9.7-SNAPSHOT"
compile 'com.github.jengelman.gradle.plugins:shadow:1.0.2'
}
mainClassName = 'App'
task jooqCodegen {
doLast {
String init = "<directory>/init.sql"
Configuration configuration = new Configuration()
.withJdbc(new Jdbc()
.withDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver")
.withUrl("jdbc:sqlserver://<server address>;DatabaseName=JOOQ; INIT=RUNSCRIPT FROM '$init'")
.withUser("****")
.withPassword("****")
)
.withGenerator(new Generator()
.withDatabase(new Database()
.withName("org.jooq.util.sqlserver.SQLServerDatabase")
.withIncludes(".*")
.withExcludes("")
.withInputSchema("dbo")
)
.withTarget(new Target()
.withDirectory("$projectDir/src/main/java")
.withPackageName("jooq")))
GenerationTool.generate(configuration)
}
}
**Note :** Added one create table statement in init.sql file
它给出了以下编译错误:
#include<iostream>
class A;
void showA(A& x) {
// Since showA() is a friend, it can access
// private members of A
std::cout << "A::a=" << x.a;
}
class A
{
int a;
public:
A() {a = 0;}
friend void showA(A& x); // global friend function
};
int main()
{
A a;
showA(a);
return 0;
}
答案 0 :(得分:3)
class A;
void showA(A& x) {
// Since showA() is a friend, it can access
// private members of A
std::cout << "A::a=" << x.a;
}
我们不知道A
会成为朋友。我们甚至不知道A
会有会员。您无法访问不完整类型的成员。尝试这样做是无效使用不完整类型。
解决方案:在访问成员之前完成类型(即定义类)。