Yuav ua li cas abstraction ua tiav hauv c?

Cov txheej txheem:

Yuav ua li cas abstraction ua tiav hauv c?
Yuav ua li cas abstraction ua tiav hauv c?
Anonim

Abstraction siv cov chav kawm: Kev paub daws teeb meem tuaj yeem ua tiav siv cov chav kawm. Ib chav kawm yog siv los pab pawg tag nrho cov ntaub ntawv cov tswv cuab thiab cov tswv cuab ua haujlwm rau hauv ib chav tsev los ntawm kev siv cov ntaub ntawv nkag mus. Ib chav kawm muaj lub luag haujlwm los txiav txim siab tus tswvcuab cov ntaub ntawv twg yuav tsum pom sab nraud thiab qhov twg tsis yog.

Yuav ua li cas thiaj ua tiav?

In java, abstraction yog ua tiav los ntawm interfaces thiab abstract classes. Peb tuaj yeem ua tiav 100% abstraction siv interfaces. Cov chav kawm paub daws teeb meem thiab cov kev paub daws teeb meem: … Txhua chav kawm uas muaj ib lossis ntau txoj kev paub daws teeb meem yuav tsum tau tshaj tawm nrog cov ntsiab lus paub daws teeb meem.

Peb puas tuaj yeem ua abstraction hauv C?

OOP yog qhov programming style uas muab cov ntaub ntawv abstraction. Koj tuaj yeem ua tiav cov ntaub ntawv abstraction hauv ntau txoj hauv kev. Nyob rau hauv tas li ntawd, nws yog zoo kawg nkaus sau nyob rau hauv ib tug object-oriented style nyob rau hauv C. Nws tsuas yog ntau verbose thiab nrov tshaj nws yog nyob rau hauv lwm yam lus.

Dab tsi yog ob txoj hauv kev kom ua tiav kev paub daws teeb meem?

Peb tuaj yeem ua tiav ob txoj hauv kev: Siv Chav Kawm Abstract . Using Interface.

Yaj lus ntawm chav kawm paub daws teeb meem yog:

  • public abstract className.
  • {
  • public abstract methodName;
  • }

Yuav ua li cas peb thiaj ua tiav abstraction hauv oops?

Abstraction yog lub tswv yim ntawm cov phiaj xwm taw qhia uas "qhia" nkaus xwbcov yam ntxwv tseem ceeb thiab "hides" cov ntaub ntawv tsis tsim nyog. Lub hom phiaj tseem ceeb ntawm abstraction yog zais cov ntsiab lus tsis tsim nyog los ntawm cov neeg siv.

Pom zoo: