当前位置: 首页>>代码示例>>C++>>正文


C++ BaseClass类代码示例

本文整理汇总了C++中BaseClass的典型用法代码示例。如果您正苦于以下问题:C++ BaseClass类的具体用法?C++ BaseClass怎么用?C++ BaseClass使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BaseClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: semantic

bool CheckSpecifier::visit(ClassSpecifierAST *ast)
{
    unsigned sourceLocation = ast->firstToken();

    if (ast->name)
        sourceLocation = ast->name->firstToken();

    const Name *className = semantic()->check(ast->name, _scope);
    Class *klass = control()->newClass(sourceLocation, className);
    klass->setStartOffset(tokenAt(ast->firstToken()).offset);
    klass->setEndOffset(tokenAt(ast->lastToken()).offset);
    ast->symbol = klass;
    unsigned classKey = tokenKind(ast->classkey_token);
    if (classKey == T_CLASS)
        klass->setClassKey(Class::ClassKey);
    else if (classKey == T_STRUCT)
        klass->setClassKey(Class::StructKey);
    else if (classKey == T_UNION)
        klass->setClassKey(Class::UnionKey);
    klass->setVisibility(semantic()->currentVisibility());
    _scope->enterSymbol(klass);
    _fullySpecifiedType.setType(klass);

    for (BaseSpecifierListAST *it = ast->base_clause_list; it; it = it->next) {
        BaseSpecifierAST *base = it->value;
        const Name *baseClassName = semantic()->check(base->name, _scope);
        BaseClass *baseClass = control()->newBaseClass(ast->firstToken(), baseClassName);
        base->symbol = baseClass;
        if (base->virtual_token)
            baseClass->setVirtual(true);
        if (base->access_specifier_token) {
            int accessSpecifier = tokenKind(base->access_specifier_token);
            int visibility = semantic()->visibilityForAccessSpecifier(accessSpecifier);
            baseClass->setVisibility(visibility);
        }
        klass->addBaseClass(baseClass);
    }

    int visibility = semantic()->visibilityForClassKey(classKey);
    int previousVisibility = semantic()->switchVisibility(visibility);
    int previousMethodKey = semantic()->switchMethodKey(Function::NormalMethod);

    DeclarationAST *previousDeclaration = 0;
    for (DeclarationListAST *it = ast->member_specifier_list; it; it = it->next) {
        DeclarationAST *declaration = it->value;
        semantic()->check(declaration, klass->members());

        if (previousDeclaration && declaration &&
                declaration->asEmptyDeclaration() != 0 &&
                previousDeclaration->asFunctionDefinition() != 0)
            translationUnit()->warning(declaration->firstToken(), "unnecessary semicolon after function body");

        previousDeclaration = declaration;
    }

    (void) semantic()->switchMethodKey(previousMethodKey);
    (void) semantic()->switchVisibility(previousVisibility);

    return false;
}
开发者ID:,项目名称:,代码行数:60,代码来源:

示例2: isInterfaceDeclaration

void ClassDeclaration::interfaceSemantic(Scope *sc)
{
    InterfaceDeclaration *id = isInterfaceDeclaration();

    vtblInterfaces = new BaseClasses();
    vtblInterfaces->reserve(interfaces_dim);

    for (size_t i = 0; i < interfaces_dim; i++)
    {
        BaseClass *b = interfaces[i];

        // If this is an interface, and it derives from a COM interface,
        // then this is a COM interface too.
        if (b->base->isCOMinterface())
            com = 1;

#if 1
        if (b->base->isCPPinterface() && id)
            id->cpp = 1;
#else
        if (b->base->isCPPinterface())
            cpp = 1;
#endif
        vtblInterfaces->push(b);
        b->copyBaseInterfaces(vtblInterfaces);
    }
}
开发者ID:NemanjaBoric,项目名称:dmd,代码行数:27,代码来源:class.c

示例3: FactoryMonitor

    /*! @brief Constructor

        @param[in] object      Reference to the class instance that is creating this SubMonitor.
        @param[in] msg         String that indicates what the SubMonitor is monitoring, e.g., "Build".
        @param[in] level       The MueLu Level object.
        @param[in] msgLevel    Governs whether information should be printed.
        @param[in] timerLevel  Governs whether timing information should be *gathered*.  Setting this to NoTimeReport prevents the creation of timers.

      TODO: code factorization
    */
    FactoryMonitor(const BaseClass& object, const std::string & msg, const Level & level, MsgType msgLevel = static_cast<MsgType>(Test | Runtime0), MsgType timerLevel = Timings0)
      : Monitor(object, msg, msgLevel, timerLevel),
      timerMonitorExclusive_(object, object.ShortClassName() + " : " + msg, timerLevel)
    {
      if (IsPrint(TimingsByLevel)) {
        levelTimeMonitor_ = rcp(new TimeMonitor(object, object.ShortClassName() + ": " +  msg + " (total, level=" + Teuchos::Utils::toString(level.GetLevelID()) + ")", timerLevel));
        levelTimeMonitorExclusive_ = rcp(new MutuallyExclusiveTimeMonitor<Level>(object, object.ShortClassName() + " " + MUELU_TIMER_AS_STRING + " : " + msg + " (level=" + Teuchos::Utils::toString(level.GetLevelID()) + ")", timerLevel));
      }
    }
开发者ID:,项目名称:,代码行数:19,代码来源:

示例4: main

int main(int argc, const char *argv[]) {
    BaseClass bcls;
    BaseClass bcls2(2.2);

    bcls.setLength(1.1);
    std::cout << bcls.getLength() << "\n";
    std::cout << bcls2.getLength() << "\n";
    return 0;
}
开发者ID:nixawk,项目名称:cpp-programming,代码行数:9,代码来源:class-constructor.cpp

示例5:

bool BaseClass::operator==(const BaseClass& c) const
{
	if(this == &c)
		return true;

	return (getNamespaceName() == c.getNamespaceName())
			&& (getClassName() == c.getClassName())
			&& (getTemplateName() == c.getTemplateName());
}
开发者ID:cguebert,项目名称:Panda,代码行数:9,代码来源:BaseClass.cpp

示例6: main

int main()
{
   BaseClass b;
   DerivedClass d;

   b.showMessage();
   d.showMessage();

   return 0;
}
开发者ID:CJavaPython,项目名称:CPT-180-27-S2016-Course-Info,代码行数:10,代码来源:Pr15-8.cpp

示例7: main

int main()
{
	SubClass* pSub = new SubClass;
	BaseClass* bClass = new SubClass;
	printf("SubClass pointer foo=%s bar=%s\n", pSub->foo(), pSub->bar() );
	printf("BaseClass Pointer foo=%s bar=%s\n", bClass->foo(), bClass->bar() );
	delete pSub;
	delete bClass;

	system("pause");
	return 0;
}
开发者ID:psytn2,项目名称:G52PP_Exercises,代码行数:12,代码来源:BaseClassAndSubClass.cpp

示例8: PrintMonitor

    //! Constructor
    PrintMonitor(const BaseClass& object, const std::string& msg, MsgType msgLevel = Runtime0) {

      // Inherit verbosity from 'object'
      SetVerbLevel(object.GetVerbLevel());
      setOStream(object.getOStream());

      // Print description and new indent
      if (IsPrint(msgLevel)) {
        GetOStream(msgLevel, 0) << msg << std::endl;
        tab_ = rcp(new Teuchos::OSTab(getOStream()));
      }

    }
开发者ID:,项目名称:,代码行数:14,代码来源:

示例9: main

// ///////////////////////////////////////////////////////////////////////
int main (int argc, char* argv[]) {

  BaseClass lBaseClass ("BaseClass");
  InheritingClass<std::string> lInheritingClass ("InheritingClass");
  lInheritingClass.addItem ("Hello ");
  lInheritingClass.addItem ("Anh Quan");
  lInheritingClass.addItem ("!");
  
  std::cout << "Base class: " << lBaseClass.toString() << std::endl;
  std::cout << "Inheriting class: " << lInheritingClass.toString() << std::endl;
  
  return 0;
}
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:14,代码来源:archi.cpp

示例10: main

 int main() 
 { 
   BaseClass *p; 
   BaseClass ob(10); 
   DerivedClass1 derivedObject1(10); 
   DerivedClass2 derivedObject2(10); 
   p = &ob; 
   p->myFunction(); // use BaseClass's myFunction() 
   p = &derivedObject1; 
   p->myFunction(); // use DerivedClass1's myFunction() 
   p = &derivedObject2; 
   p->myFunction(); // use DerivedClass2's myFunction() 
   return 0; 
 } 
开发者ID:vkgudelli,项目名称:coding,代码行数:14,代码来源:Virtual+Function.cpp

示例11: _tinherit

/*	Inherit class
 *
 */ 
void _tinherit()
{
	BaseClass A;
	A.Print();
	DerivedClass B(12,"nameb");
	B.insertMap(1,"amd");
	B.Print();
	BaseClass *BA = &A;
	BA->Print();
	BA->vprint();

	BaseClass *BA1 = &B;
	BA1->Print();
	BA1->vprint();
}
开发者ID:tenddy,项目名称:myprograms,代码行数:18,代码来源:others.cpp

示例12: SubFactoryMonitor

    /*! @brief Constructor

        @param[in] object      Reference to the class instance that is creating this SubMonitor.
        @param[in] msg         String that indicates what the SubMonitor is monitoring, e.g., "Build"
        @param[in] level       The MueLu Level object.
        @param[in] msgLevel    Governs whether information should be printed.
        @param[in] timerLevel  Governs whether timing information should be *gathered*.  Setting this to NoTimeReport prevents the creation of timers.
    */
    SubFactoryMonitor(const BaseClass& object, const std::string & msg, const Level & level, MsgType msgLevel = Runtime1, MsgType timerLevel = Timings1)
      : SubMonitor(object, msg, msgLevel, timerLevel)
    {
      if (IsPrint(TimingsByLevel)) {
        levelTimeMonitor_ = rcp(new TimeMonitor(object, object.ShortClassName() + ": " +  msg + " (sub, total, level=" + Teuchos::Utils::toString(level.GetLevelID()) + ")", timerLevel));
      }
    }
开发者ID:,项目名称:,代码行数:15,代码来源:

示例13: main

int main(int argc, char* argv[]) {
  numba a = another_file();
  MyClass c;
  deep_thing d;

  Space::foo();
  Bar::foo();

  MACRO;

  var++;

  BaseClass* der = new DerivedClass;
  der->virtualFunc();
  delete der;

  return 1;
}
开发者ID:clickyotomy,项目名称:dxr,代码行数:18,代码来源:main.cpp

示例14: _tmain

int _tmain(int argc, _TCHAR* argv[])
{
	cout<<"********BaseClass b = BaseClass()************\n";
	BaseClass* b = new BaseClass();
	cout<<"Address of Object =  "<<(int*)b<<endl;
	for(int i=0;i<sizeof(BaseClass)/4;++i)
		cout<<"Memory["<<i<<"] "<<*((int**)(b)+i)<<endl;

	cout<<"Address of VTable = "<<*(int**)(b)<<endl;
	for(int i=0;i<3;++i)
		cout<<"Memory["<<i<<"] "<<*(*(int***)(b)+i)<<endl;
	
	cout<<"Address of function1 = "<<**(int***)(b)<<endl;
	cout<<"Address of function2 = "<<*(*(int***)(b)+1)<<endl;
	b->function1();
	b->function2();

	cout<<"\n********SubClass s = SubClass()************\n";
	SubClass* s = new SubClass();
	//SubClass* s = dynamic_cast<SubClass*>(b1);
	cout<<"Address of Object =  "<<(int*)s<<endl;
	for(int i=0;i<sizeof(SubClass)/4;++i)
		cout<<"Memory["<<i<<"] "<<*((int**)(s)+i)<<endl;

	cout<<"Address of VTable = "<<*(int**)(s)<<endl;
	for(int i=0;i<3;++i)
		cout<<"Memory["<<i<<"] "<<*(*(int***)(s)+i)<<endl;
	
	cout<<"Address of function1 = "<<**(int***)(s)<<endl;
	cout<<"Address of function2 = "<<*(*(int***)(s)+1)<<endl;

	s->function1();
	s->function2();

	cout<<"\n********Class c = Class()************\n";
	Class* c = new Class();
	cout<<"Address of object: "<<(int*)c<<endl;
	//cout<<"Memory[0]: "<<*(int**)(c)<<endl;
	for(int i=0;i<sizeof(Class)/4;++i)
		cout<<"Memory["<<i<<"] "<<*((int**)(c)+i)<<endl;
	c->function1();
	
	return 0;
}
开发者ID:insanoid,项目名称:MS-ACS,代码行数:44,代码来源:vtablePointerDemo.cpp

示例15: MutuallyExclusiveTimeMonitor

     /*! @brief Constructor

        @param[in] object      Reference to the class instance that is creating this MutuallyExclusiveTimeMonitor.
        @param[in] msg         String that indicates what the Monitor is monitoring, e.g., "Build"
        @param[in] timerLevel  Governs whether timing information should be *gathered*.  Setting this to NoTimeReport prevents the creation of timers.
    */
    MutuallyExclusiveTimeMonitor(const BaseClass& object, const std::string& msg, MsgType timerLevel = Timings0)
    {
      // Inherit verbosity from 'object'
      SetVerbLevel(object.GetVerbLevel());
      setOStream(object.getOStream());

      if (IsPrint(timerLevel) &&
          /* disable timer if never printed: */ (IsPrint(RuntimeTimings) || (!IsPrint(NoTimeReport)))) {

        if (!IsPrint(NoTimeReport)) {
          timer_ = MutuallyExclusiveTime<TagName>::getNewTimer("MueLu: " + msg /*+ " (MutuallyExclusive)" */);
        } else {
          timer_ = rcp(new MutuallyExclusiveTime<TagName>     ("MueLu: " + msg /*+ " (MutuallyExclusive)" */));
        }

        timer_->start();
        timer_->incrementNumCalls();
      }
    }
开发者ID:,项目名称:,代码行数:25,代码来源:


注:本文中的BaseClass类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。