کلاس Abstract توی c++ چیه ؟ - هفت خط کد انجمن پرسش و پاسخ برنامه نویسی

کلاس Abstract توی c++ چیه ؟

+2 امتیاز
بعضی از کلاس های Qt با کلمه Abstract شروع میشن مثلا QAbstractAnimation  قضیه این Abstract چیه ؟ من هر کار کردم از این کلاس شی هم نتونستم بسازم !!
سوال شده آذر 7, 1392  بوسیله ی رامین قربانی (امتیاز 75)   5 11 15
دوباره تگ گذاری شد مهر 9, 1393 بوسیله ی BlueBlade

3 پاسخ

+2 امتیاز
 
بهترین پاسخ

اگر کلاسی کلیه متد هاش پیاده سازی نشده باشه آن وقت بهش میگن pure virtual که در این صورت معادل interface هستش اگر حداقل یک متد پیاده سازی نشده داشته باشه آن وقت کلاس abstarct هستش.

class MyInterface
{
public:
  virtual ~MyInterface() {}

  virtual void Method1() = 0;
  virtual void Method2() = 0;
};


class MyAbstract
{
public:
  virtual ~MyAbstract();

  virtual void Method1();
  virtual void Method2();
  void Method3();

  virtual void Method4() = 0; 
};

 

پاسخ داده شده آذر 7, 1392 بوسیله ی مصطفی ساتکی (امتیاز 21,998)   24 34 75
انتخاب شد آذر 8, 1392 بوسیله ی BlueBlade
چرا متد ها از نوع virtual تعریف میشن ؟
بخاطر اینکه کلاس هایی که از اون کلاس مشتق میشن بتونن همون متد را override کنند .مثلاً شما از کلاس اتومبیل 2 تا کلاس پراید و زانتیا مشتق می کنه شما میخای setGear را برای کلاس مشتق شده سفارشی کنی تو pride به فرض دنده 2 جا بخوره حداکثر شتاب می تونه 10 باشه و در زانتیا حداکثر شتاب می تونه 20 باشه
الان من چجوری از کلاس شما شی بسازم استفاده کنم این ارور میده که .
کلاس abstract واسه instance ساختن نیست باید فقط ازش کلاس دیگه را مشتق کنی.
+2 امتیاز
کلاس های Abstract کلاس هایی هستند که پیاده سازیشون به عهده برنامه نویس گذاشته شده ، یعنی برای متدهای اونها کدی نوشته نشده و برنامه نویس باید یک کلاس از اونها مشتق کنه و متدهای Abstract کلاس پدر رو درش پیاده کنه ، کلاس های Abstract یک جورهایی همون Interface هستند .
پاسخ داده شده آذر 7, 1392 بوسیله ی Felony (امتیاز 503)   2 3 10
البته ممکنه برای بعضی از متد هاشون کد نوشته شده باشه کلاسی که 1 دونه متد پیاده سازی نشده هم داشته باشه Abstract حساب میشه .
در تکمیل صحبتهای Felony باید بگم که تفاوت اصلی کلاسهای Abstract با Interface اینه که اگه یک کلاس مبتنی بر یک Interface باشه تا موقعی که همه متدهای اون اینترفیس رو پیاده سازی نکنیم برنامه کامپایل نمیشه ولی اگه کلاسمون مبتنی بر یک کلاس Abstract باشه با پیاده سازی نکردن متدهای موجود در کلاس ابسترکت پایه در کلاس جدید برنامه کامپایل میشه! یک تفاوت مهم دیگه اینه که یک کلاس میتونه به صورت همزمان از چند اینترفیس پایه استفاده کنه. قابلیت دیگه اینه که اینترفیس ها امکان مدیریت حافظه بهتری به ما می دهند که آقای Alister Christie در CodeRage 8 توضیحات مفصلی در این خصوص داده اند که می توانید برای کسب اطلاعات بیشتر به آن مراجعه کنید.
0 امتیاز
Why Engaging One State Welfare Disability Legal Professional Is Necessary.
Enlisting An State Welfare Incapability Legal Professional Proves to Be Imperative.
 
 
The Social Security Administration Administers numerous schemes from job security support to welfare assistance, and also deals with disability payments for individuals powerless to engage in employment due to protracted ailment or wound. As with every single complex group, there are policies and regulations which must be adhered to by this authority in order to get beneficial outcomes. Looking to hire a experienced SSA counsel Is important.
 
Enlisting an knowledgeable SSD lawyer can guide you navigate the challenges of SSA State Safety Net Assistance, boosting your possibility of sanction for privileges. They may make sure that your submission is lodged accurately and includes supporting medical evidence; additionally, they comprehend how to accumulate this evidence quickly so it is not submitted late; furthermore, they will avoid offering irrelevant data that can bring about obstacles and refusals by the Secure Social Assistance.
 
Your disability specialist will also equip you for a hearing with Social Security Administration if your claim is denied, by explaining what to anticipate at it and clarifying any of your questions about what happens there. They can help with offering additional proof and requesting the arbiter who heard your matter to inspect their determination and query witnesses or job experts called by Social Security to testify on your behalf, which can improve the probability that an early disability appeal succeeds if initially denied. SSD attorneys will recover any past due perks due to changes in the starting date, which denotes when your health condition began. Skilled supporters of those with disabilities will aid with recovering any past due perks that would have been lost thanks to changes in the starting date or when your condition began.
 
[url=https://disabilitysacramento.com/author/admin/page/2/]Seeking Social Security Disability benefits involves providing detailed information about the impact of your conditions on your ability to work[/url]
 
[url=http://v2sat.es/]The Essential Support Provided by the Counsel Well-Versed in Disability Law[/url] ce3_84c
پاسخ داده شده 4 روز قبل بوسیله ی MartinDag  
...