本文整理汇总了C++中B类的典型用法代码示例。如果您正苦于以下问题:C++ B类的具体用法?C++ B怎么用?C++ B使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了B类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: g
void g()
{
const B b;
int *pi;
pi = b.f(0);
}
示例2: h
void h()
{
using B::f;
using C::f;
f('h');
f(1); // { dg-error "ambiguous" }
// { dg-message "candidate" "candidate note" { target *-*-* } 22 }
void f(int); // { dg-error "previous using declaration" }
}
示例3: main
int main()
{
B b1;
const B b2 = B();
b1.f ();
b2.g ();
b2.h ();
b1.i ();
}
示例4: main
int main()
{
std::vector<A> veca(1);
std::vector<B> vecb(1);
std::cout << veca[0].geta()<<" "<<vecb[0].geta() << " " << vecb[0].getb() << std::endl;
A a;
B b;
std::cout << a.geta()<<" "<<b.geta() << " "<<b.getb() << std::endl;
std::cout << g_a.geta()<<" "<<g_b.geta() <<" "<<g_b.getb()<<std::endl;
return 0;
}
示例5: main
int main() {
using B::g;
g('a'); // calls B::g(char)
struct g g1; // g1 has class type B::g
B::h( &g1 );
if( g1.g != -34 ) _fail;
_PASS;
}
示例6: doIt
void A::doIt()
{
cout << "A::doIt" << endl;
if (aB)
{
aB->deleteTheA();
}
cout << "exit: A::doIt" << endl;
}
示例7: main
int main()
{
const B b1;
assert(b1.func() == false);
}
示例8: setBValue
//
// the following two functions access
// private member functions of class B
// and they should not be able to do so
//
virtual void setBValue(int i)
{ if (bobject) bobject->Number(i); }// ERROR - .*
示例9: set_bits_iter
explicit set_bits_iter(B const& b) : b(&b),i(b.find_first()) {}
示例10: getBValue
virtual int getBValue()
{ if (bobject) { return bobject->Number(); } return 0; }// ERROR - .*
示例11: A
namespace InhCtor {
struct A {
A(int);
protected:
int T();
};
typedef A T;
struct B : A {
// This is a using-declaration for 'int A::T()' in C++98, but is an
// inheriting constructor declaration in C++11.
using InhCtor::T::T;
};
#if __cplusplus < 201103L
B b(123); // expected-error {{no matching constructor}}
// [email protected] 2{{candidate constructor}}
int n = b.T(); // ok, accessible
#else
B b(123); // ok, inheriting constructor
int n = b.T(); // expected-error {{'T' is a protected member of 'InhCtor::A'}}
// [email protected] {{declared protected here}}
// FIXME: EDG and GCC reject this too, but it's not clear why it would be
// ill-formed.
template<typename T>
struct S : T {
struct U : S { // expected-note 6{{candidate}}
using S::S;
};
using T::T;
};
S<A>::U ua(0); // expected-error {{no match}}
S<B>::U ub(0); // expected-error {{no match}}
template<typename T>
struct X : T {
using T::Z::U::U;
};
template<typename T>
struct X2 : T {
using T::Z::template V<int>::V;
};
struct Y {
struct Z {
typedef Y U;
template<typename T> using V = Y;
};
Y(int);
};
X<Y> xy(0);
namespace Repeat {
struct A {
struct T {
T(int);
};
};
struct Z : A {
using A::A::A;
};
template<typename T>
struct ZT : T::T {
using T::T::T;
};
}
namespace NS {
struct NS {};
}
struct DerivedFromNS : NS::NS {
// No special case unless the NNS names a class.
using InhCtor::NS::NS; // expected-error {{using declaration in class refers into 'InhCtor::NS::', which is not a class}}
};
// FIXME: Consider reusing the same diagnostic between dependent and non-dependent contexts
typedef int I;
struct UsingInt {
using I::I; // expected-error {{'I' (aka 'int') is not a class, namespace, or enumeration}}
};
template<typename T> struct UsingIntTemplate {
using T::T; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}}
};
UsingIntTemplate<int> uit; // expected-note {{here}}
#endif
}
示例12: data
/// Access a non-zero element
inline DataType& at(int k) {
try {
if (k<0) k+=nnz();
return data().at(k);
} catch(std::out_of_range& /* unnamed */) {
std::stringstream ss;
ss << "Out of range error in Matrix<>::at: " << k << " not in range [0, " << nnz() << ")";
throw CasadiException(ss.str());
}
}
示例13:
int
main()
{
abc = 0xcafe0210;
#if 1
char x = 0xff;
short y = 0xcafe;
A b;
b.x = 0xcafe0110;
b.y = 0xcafe0111;
b.foo();
D d;
d.foo();
d.x = 0xcafe0112;
#endif
return 0;
}
示例14: test
void A::test()
{
if (b->fun_use_thread() == 0)
{
while(global->per < 100)
{
key = getch();
if ( (dem < 100) && (key != '\n'))
{
s[dem] = key;
s[dem + 1] = '\0';
dem ++;
}
}
}else
{
printf("Can not creat thread\n");
}
}
示例15: at
typename base::Field at(typename base::Coord x) {
return left.at(x) + right.at(x);
}