Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1602 connectés 

  FORUM HardWare.fr
  Programmation
  C++

  retourner un tableau de string!

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

retourner un tableau de string!

n°1710110
drazor
Posté le 31-03-2008 à 10:44:10  profilanswer
 

comment c'est qu'on fait?
 
merci!


---------------
si un jour on te reproche que ton travail n'est pas celui d'un professionel . dit toi bien que se sont des professionels qui on construit le titanic et des amateurs l'arche de noë...
mood
Publicité
Posté le 31-03-2008 à 10:44:10  profilanswer
 

n°1710112
masklinn
í dag viðrar vel til loftárása
Posté le 31-03-2008 à 10:45:19  profilanswer
 

bleu


---------------
Stick a parrot in a Call of Duty lobby, and you're gonna get a racist parrot. — Cody
n°1710114
drazor
Posté le 31-03-2008 à 10:45:41  profilanswer
 

???

n°1710115
masklinn
í dag viðrar vel til loftárása
Posté le 31-03-2008 à 10:46:09  profilanswer
 

!!!


---------------
Stick a parrot in a Call of Duty lobby, and you're gonna get a racist parrot. — Cody
n°1710121
_darkalt3_
Proctopathe
Posté le 31-03-2008 à 10:51:25  profilanswer
 

pomme


---------------
Töp of the plöp
n°1710122
_darkalt3_
Proctopathe
Posté le 31-03-2008 à 10:51:43  profilanswer
 

Ah non pardon:
42 est correct.


---------------
Töp of the plöp
n°1710137
drazor
Posté le 31-03-2008 à 11:07:34  profilanswer
 

vous ignorez la réponse!! haha

n°1710144
masklinn
í dag viðrar vel til loftárása
Posté le 31-03-2008 à 11:10:50  profilanswer
 

ho ho ho
http://library2.nalis.gov.tt/Portals/0/601/SantaClaus.jpg


---------------
Stick a parrot in a Call of Duty lobby, and you're gonna get a racist parrot. — Cody
n°1710160
ptitchep
Posté le 31-03-2008 à 11:19:59  profilanswer
 

#include <climits>
#include <boost/limits.hpp>
#include <boost/static_assert.hpp>
 
template <class UnsignedInt>
class myclass
{
private:
   BOOST_STATIC_ASSERT(sizeof(UnsignedInt) * CHAR_BIT >= 16);
   BOOST_STATIC_ASSERT(std::numeric_limits<UnsignedInt>::is_specialized
                        && std::numeric_limits<UnsignedInt>::is_integer
                        && !std::numeric_limits<UnsignedInt>::is_signed);
public:
   /* details here */
};
 
myclass<unsigned>      m1; // this should be OK
//myclass<int>           m2; // this should fail
myclass<unsigned char> m3; // and so should this
 
int main()
{
   return 0;
}


---------------
deluser --remove-home ptitchep
n°1710170
masklinn
í dag viðrar vel til loftárása
Posté le 31-03-2008 à 11:27:24  profilanswer
 

Code :
  1. {-# LANGUAGE ExistentialQuantification, FlexibleInstances, GeneralizedNewtypeDeriving,
  2.             MultiParamTypeClasses, TypeSynonymInstances, CPP #-}
  3. -- required for deriving Typeable
  4. {-# OPTIONS_GHC -fglasgow-exts #-}
  5. -----------------------------------------------------------------------------
  6. -- |
  7. -- Module      :  XMonad.Core
  8. -- Copyright   :  (c) Spencer Janssen 2007
  9. -- License     :  BSD3-style (see LICENSE)
  10. --
  11. -- Maintainer  :  sjanssen@cse.unl.edu
  12. -- Stability   :  unstable
  13. -- Portability :  not portable, uses cunning newtype deriving
  14. --
  15. -- The X monad, a state monad transformer over IO, for the window
  16. -- manager state, and support routines.
  17. --
  18. -----------------------------------------------------------------------------
  19. module XMonad.Core (
  20.    X, WindowSet, WindowSpace, WorkspaceId,
  21.    ScreenId(..), ScreenDetail(..), XState(..),
  22.    XConf(..), XConfig(..), LayoutClass(..),
  23.    Layout(..), readsLayout, Typeable, Message,
  24.    SomeMessage(..), fromMessage, LayoutMessages(..),
  25.    runX, catchX, userCode, io, catchIO, doubleFork,
  26.    withDisplay, withWindowSet, isRoot, runOnWorkspaces,
  27.    getAtom, spawn, getXMonadDir, recompile, trace, whenJust, whenX,
  28.    atom_WM_STATE, atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW, ManageHook, Query(..), runQuery
  29.  ) where
  30. import XMonad.StackSet hiding (modify)
  31. import Prelude hiding ( catch )
  32. import Control.Exception (catch, bracket, throw, Exception(ExitException))
  33. import Control.Applicative
  34. import Control.Monad.State
  35. import Control.Monad.Reader
  36. import System.IO
  37. import System.Info
  38. import System.Posix.Process (executeFile, forkProcess, getProcessStatus, createSession)
  39. import System.Process
  40. import System.Directory
  41. import System.Exit
  42. import Graphics.X11.Xlib
  43. import Graphics.X11.Xlib.Extras (Event)
  44. import Data.Typeable
  45. import Data.Monoid
  46. import qualified Data.Map as M
  47. import qualified Data.Set as S
  48. -- | XState, the (mutable) window manager state.
  49. data XState = XState
  50.    { windowset    :: !WindowSet           -- ^ workspace list
  51.    , mapped       :: !(S.Set Window)      -- ^ the Set of mapped windows
  52.    , waitingUnmap :: !(M.Map Window Int)  -- ^ the number of expected UnmapEvents
  53.    , dragging     :: !(Maybe (Position -> Position -> X (), X ())) }
  54. -- | XConf, the (read-only) window manager configuration.
  55. data XConf = XConf
  56.    { display       :: Display        -- ^ the X11 display
  57.    , config        :: !(XConfig Layout)       -- ^ initial user configuration
  58.    , theRoot       :: !Window        -- ^ the root window
  59.    , normalBorder  :: !Pixel         -- ^ border color of unfocused windows
  60.    , focusedBorder :: !Pixel         -- ^ border color of the focused window
  61.    , keyActions    :: !(M.Map (KeyMask, KeySym) (X ()))
  62.                                      -- ^ a mapping of key presses to actions
  63.    , buttonActions :: !(M.Map (KeyMask, Button) (Window -> X ()))
  64.                                      -- ^ a mapping of button presses to actions
  65.    }
  66. -- todo, better name
  67. data XConfig l = XConfig
  68.    { normalBorderColor  :: !String              -- ^ Non focused windows border color. Default: \"#dddddd\"
  69.    , focusedBorderColor :: !String              -- ^ Focused windows border color. Default: \"#ff0000\"
  70.    , terminal           :: !String              -- ^ The preferred terminal application. Default: \"xterm\"
  71.    , layoutHook         :: !(l Window)          -- ^ The available layouts
  72.    , manageHook         :: !ManageHook          -- ^ The action to run when a new window is opened
  73.    , workspaces         :: ![String]            -- ^ The list of workspaces' names
  74.    , numlockMask        :: !KeyMask             -- ^ The numlock modifier
  75.    , modMask            :: !KeyMask             -- ^ the mod modifier
  76.    , keys               :: !(XConfig Layout -> M.Map (ButtonMask,KeySym) (X ()))
  77.                                                 -- ^ The key binding: a map from key presses and actions
  78.    , mouseBindings      :: !(XConfig Layout -> M.Map (ButtonMask, Button) (Window -> X ()))
  79.                                                 -- ^ The mouse bindings
  80.    , borderWidth        :: !Dimension           -- ^ The border width
  81.    , logHook            :: !(X ())              -- ^ The action to perform when the windows set is changed
  82.    , startupHook        :: !(X ())              -- ^ The action to perform on startup
  83.    , focusFollowsMouse  :: !Bool                -- ^ Whether window entry events can change focus
  84.    }
  85. type WindowSet   = StackSet  WorkspaceId (Layout Window) Window ScreenId ScreenDetail
  86. type WindowSpace = Workspace WorkspaceId (Layout Window) Window
  87. -- | Virtual workspace indices
  88. type WorkspaceId = String
  89. -- | Physical screen indices
  90. newtype ScreenId    = S Int deriving (Eq,Ord,Show,Read,Enum,Num,Integral,Real)
  91. -- | The 'Rectangle' with screen dimensions
  92. data ScreenDetail   = SD { screenRect :: !Rectangle } deriving (Eq,Show, Read)
  93. ------------------------------------------------------------------------
  94. -- | The X monad, ReaderT and StateT transformers over IO
  95. -- encapsulating the window manager configuration and state,
  96. -- respectively.
  97. --
  98. -- Dynamic components may be retrieved with 'get', static components
  99. -- with 'ask'. With newtype deriving we get readers and state monads
  100. -- instantiated on XConf and XState automatically.
  101. --
  102. newtype X a = X (ReaderT XConf (StateT XState IO) a)
  103. #ifndef __HADDOCK__
  104.    deriving (Functor, Monad, MonadIO, MonadState XState, MonadReader XConf)
  105. #endif
  106. instance Applicative X where
  107.  pure = return
  108.  (<*> ) = ap
  109. instance (Monoid a) => Monoid (X a) where
  110.    mempty  = return mempty
  111.    mappend = liftM2 mappend
  112. type ManageHook = Query (Endo WindowSet)
  113. newtype Query a = Query (ReaderT Window X a)
  114. #ifndef __HADDOCK__
  115.    deriving (Functor, Monad, MonadReader Window, MonadIO)
  116. #endif
  117. runQuery :: Query a -> Window -> X a
  118. runQuery (Query m) w = runReaderT m w
  119. instance Monoid a => Monoid (Query a) where
  120.    mempty  = return mempty
  121.    mappend = liftM2 mappend
  122. -- | Run the X monad, given a chunk of X monad code, and an initial state
  123. -- Return the result, and final state
  124. runX :: XConf -> XState -> X a -> IO (a, XState)
  125. runX c st (X a) = runStateT (runReaderT a c) st
  126. -- | Run in the X monad, and in case of exception, and catch it and log it
  127. -- to stderr, and run the error case.
  128. catchX :: X a -> X a -> X a
  129. catchX job errcase = do
  130.    st <- get
  131.    c <- ask
  132.    (a, s') <- io $ runX c st job `catch` \e -> case e of
  133.                            ExitException {} -> throw e
  134.                            _ -> do hPrint stderr e; runX c st errcase
  135.    put s'
  136.    return a
  137. -- | Execute the argument, catching all exceptions.  Either this function or
  138. -- catchX should be used at all callsites of user customized code.
  139. userCode :: X () -> X ()
  140. userCode a = catchX (a >> return ()) (return ())
  141. -- ---------------------------------------------------------------------
  142. -- Convenient wrappers to state
  143. -- | Run a monad action with the current display settings
  144. withDisplay :: (Display -> X a) -> X a
  145. withDisplay   f = asks display >>= f
  146. -- | Run a monadic action with the current stack set
  147. withWindowSet :: (WindowSet -> X a) -> X a
  148. withWindowSet f = gets windowset >>= f
  149. -- | True if the given window is the root window
  150. isRoot :: Window -> X Bool
  151. isRoot w = (w==) <$> asks theRoot
  152. -- | Wrapper for the common case of atom internment
  153. getAtom :: String -> X Atom
  154. getAtom str = withDisplay $ \dpy -> io $ internAtom dpy str False
  155. -- | Common non-predefined atoms
  156. atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW, atom_WM_STATE :: X Atom
  157. atom_WM_PROTOCOLS       = getAtom "WM_PROTOCOLS"
  158. atom_WM_DELETE_WINDOW   = getAtom "WM_DELETE_WINDOW"
  159. atom_WM_STATE           = getAtom "WM_STATE"
  160. ------------------------------------------------------------------------
  161. -- LayoutClass handling. See particular instances in Operations.hs
  162. -- | An existential type that can hold any object that is in 'Read'
  163. --   and 'LayoutClass'.
  164. data Layout a = forall l. (LayoutClass l a, Read (l a)) => Layout (l a)
  165. -- | Using the 'Layout' as a witness, parse existentially wrapped windows
  166. -- from a 'String'.
  167. readsLayout :: Layout a -> String -> [(Layout a, String)]
  168. readsLayout (Layout l) s = [(Layout (asTypeOf x l), rs) | (x, rs) <- reads s]
  169. -- | Every layout must be an instance of 'LayoutClass', which defines
  170. -- the basic layout operations along with a sensible default for each.
  171. --
  172. -- Minimal complete definition:
  173. --
  174. -- * 'runLayout' || (('doLayout' || 'pureLayout') && 'emptyLayout'), and
  175. --
  176. -- * 'handleMessage' || 'pureMessage'
  177. --
  178. -- You should also strongly consider implementing 'description',
  179. -- although it is not required.
  180. --
  181. -- Note that any code which /uses/ 'LayoutClass' methods should only
  182. -- ever call 'runLayout', 'handleMessage', and 'description'!  In
  183. -- other words, the only calls to 'doLayout', 'pureMessage', and other
  184. -- such methods should be from the default implementations of
  185. -- 'runLayout', 'handleMessage', and so on.  This ensures that the
  186. -- proper methods will be used, regardless of the particular methods
  187. -- that any 'LayoutClass' instance chooses to define.
  188. class Show (layout a) => LayoutClass layout a where
  189.    -- | By default, 'runLayout' calls 'doLayout' if there are any
  190.    --   windows to be laid out, and 'emptyLayout' otherwise.  Most
  191.    --   instances of 'LayoutClass' probably do not need to implement
  192.    --   'runLayout'; it is only useful for layouts which wish to make
  193.    --   use of more of the 'Workspace' information (for example,
  194.    --   "XMonad.Layout.PerWorkspace" ).
  195.    runLayout :: Workspace WorkspaceId (layout a) a
  196.              -> Rectangle
  197.              -> X ([(a, Rectangle)], Maybe (layout a))
  198.    runLayout (Workspace _ l ms) r = maybe (emptyLayout l r) (doLayout l r) ms
  199.    -- | Given a 'Rectangle' in which to place the windows, and a 'Stack'
  200.    -- of windows, return a list of windows and their corresponding
  201.    -- Rectangles.  If an element is not given a Rectangle by
  202.    -- 'doLayout', then it is not shown on screen.  The order of
  203.    -- windows in this list should be the desired stacking order.
  204.    --
  205.    -- Also possibly return a modified layout (by returning @Just
  206.    -- newLayout@), if this layout needs to be modified (e.g. if it
  207.    -- keeps track of some sort of state).  Return @Nothing@ if the
  208.    -- layout does not need to be modified.
  209.    --
  210.    -- Layouts which do not need access to the 'X' monad ('IO', window
  211.    -- manager state, or configuration) and do not keep track of their
  212.    -- own state should implement 'pureLayout' instead of 'doLayout'.
  213.    doLayout    :: layout a -> Rectangle -> Stack a
  214.                -> X ([(a, Rectangle)], Maybe (layout a))
  215.    doLayout l r s   = return (pureLayout l r s, Nothing)
  216.    -- | This is a pure version of 'doLayout', for cases where we
  217.    -- don't need access to the 'X' monad to determine how to lay out
  218.    -- the windows, and we don't need to modify the layout itself.
  219.    pureLayout  :: layout a -> Rectangle -> Stack a -> [(a, Rectangle)]
  220.    pureLayout _ r s = [(focus s, r)]
  221.    -- | 'emptyLayout' is called when there are no windows.
  222.    emptyLayout :: layout a -> Rectangle -> X ([(a, Rectangle)], Maybe (layout a))
  223.    emptyLayout _ _ = return ([], Nothing)
  224.    -- | 'handleMessage' performs message handling.  If
  225.    -- 'handleMessage' returns @Nothing@, then the layout did not
  226.    -- respond to the message and the screen is not refreshed.
  227.    -- Otherwise, 'handleMessage' returns an updated layout and the
  228.    -- screen is refreshed.
  229.    --
  230.    -- Layouts which do not need access to the 'X' monad to decide how
  231.    -- to handle messages should implement 'pureMessage' instead of
  232.    -- 'handleMessage' (this restricts the risk of error, and makes
  233.    -- testing much easier).
  234.    handleMessage :: layout a -> SomeMessage -> X (Maybe (layout a))
  235.    handleMessage l  = return . pureMessage l
  236.    -- | Respond to a message by (possibly) changing our layout, but
  237.    -- taking no other action.  If the layout changes, the screen will
  238.    -- be refreshed.
  239.    pureMessage :: layout a -> SomeMessage -> Maybe (layout a)
  240.    pureMessage _ _  = Nothing
  241.    -- | This should be a human-readable string that is used when
  242.    -- selecting layouts by name.  The default implementation is
  243.    -- 'show', which is in some cases a poor default.
  244.    description :: layout a -> String
  245.    description      = show
  246. instance LayoutClass Layout Window where
  247.    runLayout (Workspace i (Layout l) ms) r = fmap (fmap Layout) `fmap` runLayout (Workspace i l ms) r
  248.    doLayout (Layout l) r s  = fmap (fmap Layout) `fmap` doLayout l r s
  249.    emptyLayout (Layout l) r = fmap (fmap Layout) `fmap` emptyLayout l r
  250.    handleMessage (Layout l) = fmap (fmap Layout) . handleMessage l
  251.    description (Layout l)   = description l
  252. instance Show (Layout a) where show (Layout l) = show l
  253. -- | Based on ideas in /An Extensible Dynamically-Typed Hierarchy of
  254. -- Exceptions/, Simon Marlow, 2006. Use extensible messages to the
  255. -- 'handleMessage' handler.
  256. --
  257. -- User-extensible messages must be a member of this class.
  258. --
  259. class Typeable a => Message a
  260. -- |
  261. -- A wrapped value of some type in the 'Message' class.
  262. --
  263. data SomeMessage = forall a. Message a => SomeMessage a
  264. -- |
  265. -- And now, unwrap a given, unknown 'Message' type, performing a (dynamic)
  266. -- type check on the result.
  267. --
  268. fromMessage :: Message m => SomeMessage -> Maybe m
  269. fromMessage (SomeMessage m) = cast m
  270. -- X Events are valid Messages.
  271. instance Message Event
  272. -- | 'LayoutMessages' are core messages that all layouts (especially stateful
  273. -- layouts) should consider handling.
  274. data LayoutMessages = Hide              -- ^ sent when a layout becomes non-visible
  275.                    | ReleaseResources  -- ^ sent when xmonad is exiting or restarting
  276.    deriving (Typeable, Eq)
  277. instance Message LayoutMessages
  278. -- ---------------------------------------------------------------------
  279. -- | General utilities
  280. --
  281. -- Lift an IO action into the X monad
  282. io :: MonadIO m => IO a -> m a
  283. io = liftIO
  284. -- | Lift an IO action into the X monad.  If the action results in an IO
  285. -- exception, log the exception to stderr and continue normal execution.
  286. catchIO :: MonadIO m => IO () -> m ()
  287. catchIO f = io (f `catch` \e -> hPrint stderr e >> hFlush stderr)
  288. -- | spawn. Launch an external application
  289. spawn :: MonadIO m => String -> m ()
  290. spawn x = doubleFork $ executeFile "/bin/sh" False ["-c", x] Nothing
  291. -- | Double fork and execute an IO action (usually one of the exec family of
  292. -- functions)
  293. doubleFork :: MonadIO m => IO () -> m ()
  294. doubleFork m = io $ do
  295.    pid <- forkProcess $ do
  296.        forkProcess (createSession >> m)
  297.        exitWith ExitSuccess
  298.    getProcessStatus True False pid
  299.    return ()
  300. -- | This is basically a map function, running a function in the X monad on
  301. -- each workspace with the output of that function being the modified workspace.
  302. runOnWorkspaces :: (WindowSpace -> X WindowSpace) -> X ()
  303. runOnWorkspaces job = do
  304.    ws <- gets windowset
  305.    h <- mapM job $ hidden ws
  306.    c:v <- mapM (\s -> (\w -> s { workspace = w}) <$> job (workspace s))
  307.             $ current ws : visible ws
  308.    modify $ \s -> s { windowset = ws { current = c, visible = v, hidden = h } }
  309. -- | Return the path to @~\/.xmonad@.
  310. getXMonadDir :: MonadIO m => m String
  311. getXMonadDir = io $ getAppUserDataDirectory "xmonad"
  312. -- | 'recompile force', recompile @~\/.xmonad\/xmonad.hs@ when any of the
  313. -- following apply:
  314. --      * force is True
  315. --      * the xmonad executable does not exist
  316. --      * the xmonad executable is older than xmonad.hs
  317. --
  318. -- The -i flag is used to restrict recompilation to the xmonad.hs file only.
  319. --
  320. -- Compilation errors (if any) are logged to ~\/.xmonad\/xmonad.errors.  If
  321. -- GHC indicates failure with a non-zero exit code, an xmessage displaying
  322. -- that file is spawned.
  323. --
  324. -- False is returned if there are compilation errors.
  325. --
  326. recompile :: MonadIO m => Bool -> m Bool
  327. recompile force = io $ do
  328.    dir <- getXMonadDir
  329.    let binn = "xmonad-"++arch++"-"++os
  330.        bin  = dir ++ "/" ++ binn
  331.        base = dir ++ "/" ++ "xmonad"
  332.        err  = base ++ ".errors"
  333.        src  = base ++ ".hs"
  334.    srcT <- getModTime src
  335.    binT <- getModTime bin
  336.    if (force || srcT > binT)
  337.      then do
  338.        status <- bracket (openFile err WriteMode) hClose $ \h -> do
  339.            waitForProcess =<< runProcess "ghc" ["--make", "xmonad.hs", "-i", "-no-recomp", "-v0", "-o",binn] (Just dir)
  340.                                    Nothing Nothing Nothing (Just h)
  341.        -- now, if it fails, run xmessage to let the user know:
  342.        when (status /= ExitSuccess) $ do
  343.            ghcErr <- readFile err
  344.            let msg = unlines $
  345.                    ["Error detected while loading xmonad configuration file: " ++ src]
  346.                    ++ lines ghcErr ++ ["","Please check the file for errors."]
  347.            -- nb, the ordering of printing, then forking, is crucial due to
  348.            -- lazy evaluation
  349.            hPutStrLn stderr msg
  350.            doubleFork $ executeFile "xmessage" True ["-default", "okay", msg] Nothing
  351.        return (status == ExitSuccess)
  352.      else return True
  353. where getModTime f = catch (Just <$> getModificationTime f) (const $ return Nothing)
  354. -- | Conditionally run an action, using a @Maybe a@ to decide.
  355. whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()
  356. whenJust mg f = maybe (return ()) f mg
  357. -- | Conditionally run an action, using a X event to decide
  358. whenX :: X Bool -> X () -> X ()
  359. whenX a f = a >>= \b -> when b f
  360. -- | A 'trace' for the X monad. Logs a string to stderr. The result may
  361. -- be found in your .xsession-errors file
  362. trace :: MonadIO m => String -> m ()
  363. trace = io . hPutStrLn stderr


---------------
Stick a parrot in a Call of Duty lobby, and you're gonna get a racist parrot. — Cody
mood
Publicité
Posté le 31-03-2008 à 11:27:24  profilanswer
 

n°1710237
Joel F
Real men use unique_ptr
Posté le 31-03-2008 à 13:03:58  profilanswer
 

plus serieusement
 

Code :
  1. vector<string> f();

n°1710329
drazor
Posté le 31-03-2008 à 14:46:00  profilanswer
 

Faut faire du passage par référence?

n°1710333
_darkalt3_
Proctopathe
Posté le 31-03-2008 à 14:49:02  profilanswer
 

Ca dépend.


---------------
Töp of the plöp
n°1710336
drazor
Posté le 31-03-2008 à 14:49:45  profilanswer
 

de quoi?

n°1710340
_darkalt3_
Proctopathe
Posté le 31-03-2008 à 14:55:06  profilanswer
 

de ce que tu veux faire ?


---------------
Töp of the plöp
n°1710342
drazor
Posté le 31-03-2008 à 14:56:36  profilanswer
 

je résume
dans ma méthode de récup des info d'un fichier txt, jusqu'a là ok. Je les stocks dans un tableau de string: sa ok. Et pour que je récupe ce tableau hors de ma méthode je fait comment! je vais pas retourner mon pointeur!

n°1710456
Elmoricq
Modérateur
Posté le 31-03-2008 à 16:28:47  profilanswer
 

Pointeur ? Qu'est-ce que tu fais avec un pointeur ? :heink:
 
Joel F t'a donne la reponse : vector<string>
 
Plus d'infos ici : http://cplusplus.com

n°1710602
drazor
Posté le 31-03-2008 à 19:37:23  profilanswer
 

tu redefini mon besoin...
répond à ma question.

n°1710606
Elmoricq
Modérateur
Posté le 31-03-2008 à 19:41:52  profilanswer
 

Hein ? [:quardelitre dei]

 

Je redefinis rien du tout, je t'indique juste la methode qu'on utilise habituellement en C++, c'est-a-dire l'emploi des STL containers qui sont fait pour ca, et qui t'evitent de jouer avec new/delete pour des trucs aussi triviaux que ce que tu cherches a faire.

 

Poste le bout de code qui te pose probleme qu'on y jette un oeil...


Message édité par Elmoricq le 31-03-2008 à 19:42:30
n°1710805
BenO
Profil: Chercheur
Posté le 01-04-2008 à 09:31:11  profilanswer
 

un passage par référence ?  [:cerveau zytrasnif]


---------------
Python Python Python
n°1710847
Joel F
Real men use unique_ptr
Posté le 01-04-2008 à 10:43:28  profilanswer
 

Code :
  1. class totoz
  2. {
  3.    public:
  4.    // FCC & requried methods
  5.    // Si tu  n'as pas a modifié le vector à l'exterieru :
  6.   const vector<string>& load()
  7.   {
  8.     // ...
  9.     return mFileContent;
  10.   }
  11.   // sinon copie
  12.   vector<string> load()
  13.   {
  14.     // ...
  15.     return mFileContent;
  16.   }
  17.   private :
  18.   vector<string> mFileCOntent;
  19. };


n°1728670
drazor
Posté le 05-05-2008 à 16:35:50  profilanswer
 

Je viens de mettre le nez dans les vector et la stl en général c'est à pleurer tellement c'est beau.
Je suis un crétin de vous avoir envoyé baladé comme sa!
Merci de votre aide.

mood
Publicité
Posté le   profilanswer
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C++

  retourner un tableau de string!

 

Sujets relatifs
récupérer les donnees d'un fichier ds 1 tableau pythonpassage de l'intérieur d'un tableau par référence dans une fonction ?
Comparaison et Remplacement StringString not declared malgré le #include <string>
[PHP] Petit soucis de tableau d'un objetSeparer les mots d'un string, sans les couper
comment faire un tableau en VHDL ?Word et tableau dynamique
[JS] Cacher les lignes d'un tableautableau et couleur
Plus de sujets relatifs à : retourner un tableau de string!


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR